Skip to content

Commit

Permalink
fix findHostInstance_DEPRECATED import
Browse files Browse the repository at this point in the history
  • Loading branch information
jakex7 committed Dec 10, 2024
1 parent ac7e786 commit a20adca
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/getShadowNodeFromRef.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,16 @@ export function getShadowNodeFromRef(ref: unknown) {
// Load findHostInstance_DEPRECATED lazily because it may not be available before render
if (findHostInstance_DEPRECATED === undefined) {
try {
// eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-unsafe-assignment
const ReactFabric = require('react-native/Libraries/Renderer/shims/ReactFabric');
// Since RN 0.77 ReactFabric exports findHostInstance_DEPRECATED in default object so we're trying to
// access it first, then fallback on named export
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
findHostInstance_DEPRECATED =
// eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-unsafe-member-access
require('react-native/Libraries/Renderer/shims/ReactFabric').findHostInstance_DEPRECATED;
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
ReactFabric?.default?.findHostInstance_DEPRECATED ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
ReactFabric?.findHostInstance_DEPRECATED;
} catch (e) {
findHostInstance_DEPRECATED = (_ref: unknown) => null;
}
Expand Down

0 comments on commit a20adca

Please sign in to comment.