Skip to content

Commit

Permalink
Compatibility with 0.77 for findHostInstance (#6883)
Browse files Browse the repository at this point in the history
## Summary

The method findHostInstance in [email protected] has been moved from a
named export to the default export. This PR fix compatibility issue.

## Test plan

Run application with `[email protected]`
  • Loading branch information
piaskowyk authored Jan 10, 2025
1 parent 1bc31af commit 333934b
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,24 @@ function resolveFindHostInstance_DEPRECATED() {
}
if (isFabric()) {
try {
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
findHostInstance_DEPRECATED =
require('react-native/Libraries/Renderer/shims/ReactFabric').findHostInstance_DEPRECATED;
ReactFabric?.default?.findHostInstance_DEPRECATED ??
ReactFabric?.findHostInstance_DEPRECATED;
} catch (e) {
throw new ReanimatedError(
'Failed to resolve findHostInstance_DEPRECATED'
);
}
} else {
const ReactNative = require('react-native/Libraries/Renderer/shims/ReactNative');
// Since RN 0.77 ReactFabric exports findHostInstance_DEPRECATED in default object so we're trying to
// access it first, then fallback on named export
findHostInstance_DEPRECATED =
require('react-native/Libraries/Renderer/shims/ReactNative').findHostInstance_DEPRECATED;
ReactNative?.default?.findHostInstance_DEPRECATED ??
ReactNative?.findHostInstance_DEPRECATED;
}
}

Expand Down

0 comments on commit 333934b

Please sign in to comment.