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 react-native@0.77 has been moved from a
named export to the default export. This PR fix compatibility issue.

## Test plan

Run application with `react-native@0.77`
  • Loading branch information
piaskowyk authored and tomekzaw committed Jan 10, 2025
1 parent 502fec1 commit f85a6d7
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 f85a6d7

Please sign in to comment.