-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor findNodeHandler #6736
Refactor findNodeHandler #6736
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me overall. Make sure to test it with the newest Gesture Handler and SVG on their more complex examples, since they used to have cases where these refs mechanisms broke.
packages/react-native-reanimated/src/createAnimatedComponent/createAnimatedComponent.tsx
Outdated
Show resolved
Hide resolved
packages/react-native-reanimated/src/createAnimatedComponent/createAnimatedComponent.tsx
Show resolved
Hide resolved
packages/react-native-reanimated/src/createAnimatedComponent/createAnimatedComponent.tsx
Outdated
Show resolved
Hide resolved
packages/react-native-reanimated/src/createAnimatedComponent/NativeEventsManager.ts
Show resolved
Hide resolved
packages/react-native-reanimated/src/createAnimatedComponent/NativeEventsManager.ts
Outdated
Show resolved
Hide resolved
packages/react-native-reanimated/src/createAnimatedComponent/NativeEventsManager.ts
Outdated
Show resolved
Hide resolved
packages/react-native-reanimated/src/createAnimatedComponent/NativeEventsManager.ts
Outdated
Show resolved
Hide resolved
packages/react-native-reanimated/src/createAnimatedComponent/NativeEventsManager.ts
Outdated
Show resolved
Hide resolved
packages/react-native-reanimated/src/createAnimatedComponent/createAnimatedComponent.tsx
Show resolved
Hide resolved
packages/react-native-reanimated/src/platform-specific/RNRenderer.ts
Outdated
Show resolved
Hide resolved
packages/react-native-reanimated/src/createAnimatedComponent/commonTypes.ts
Show resolved
Hide resolved
packages/react-native-reanimated/src/platform-specific/RNRenderer.ts
Outdated
Show resolved
Hide resolved
packages/react-native-reanimated/src/platform-specific/RNRenderer.ts
Outdated
Show resolved
Hide resolved
packages/react-native-reanimated/src/createAnimatedComponent/NativeEventsManager.ts
Show resolved
Hide resolved
packages/react-native-reanimated/src/createAnimatedComponent/createAnimatedComponent.tsx
Outdated
Show resolved
Hide resolved
packages/react-native-reanimated/src/platform-specific/RNRenderer.ts
Outdated
Show resolved
Hide resolved
packages/react-native-reanimated/src/platform-specific/RNRenderer.ts
Outdated
Show resolved
Hide resolved
packages/react-native-reanimated/src/platform-specific/RNRenderer.ts
Outdated
Show resolved
Hide resolved
packages/react-native-reanimated/src/platform-specific/RNRenderer.ts
Outdated
Show resolved
Hide resolved
packages/react-native-reanimated/src/createAnimatedComponent/NativeEventsManager.ts
Outdated
Show resolved
Hide resolved
packages/react-native-reanimated/src/platform-specific/RNRenderer.ts
Outdated
Show resolved
Hide resolved
packages/react-native-reanimated/src/platform-specific/RNRenderer.ts
Outdated
Show resolved
Hide resolved
packages/react-native-reanimated/src/platform-specific/RNRenderer.ts
Outdated
Show resolved
Hide resolved
packages/react-native-reanimated/src/platform-specific/RNRenderer.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's go!
packages/react-native-reanimated/src/platform-specific/findHostInstance.ts
Outdated
Show resolved
Hide resolved
packages/react-native-reanimated/src/platform-specific/findHostInstance.ts
Outdated
Show resolved
Hide resolved
packages/react-native-reanimated/src/platform-specific/RNRenderer.ts
Outdated
Show resolved
Hide resolved
## Summary This PR addresses the issue reported at [https://github.com/software-mansion/react-native-reanimated/issues/6719](https://github.com/software-mansion/react-native-reanimated/issues/6719) and aims to: - **Unify the method used to obtain the view tag**, as there are currently several approaches. - **Avoid passing a class component to the findNodeHandler**. Instead, we'll pass a ref to the component, similar to what Expo implemented here: [https://github.com/expo/expo/pull/33016](https://github.com/expo/expo/pull/33016). - **Limit unnecessary invocations of findNodeHandler** to no more than one call per render. - **Remove the invocation of findHostInstance from Paper renderer** on the New Architecture. **Additional Remarks:** - When a class component is passed to `createAnimatedComponent`, it will still fall back to the slow path where we can get a native ref. - In `NativeEventManager`, we need to call findNodeHandler again after every render to ensure that the children of `<GestureDetector />` haven't changed their native tags. - `LayoutAnimationConfig` still uses findNodeHandler. It requires a complete refactor of their functionality to eliminate its use, and I plan to handle this in another PR. - `findHostInstance_DEPRECATED` always follows the slow path even for native refs, which is why I've implemented our own version of `findHostInstance` to optimize the happy path. Fixes #6719 Related PRs: - #6030 - #5960 - #4445 - expo/expo#33016 ## Test plan - [x] check Paper - [x] check Fabric - [x] check Web
## Summary This PR addresses the issue reported at [https://github.com/software-mansion/react-native-reanimated/issues/6719](https://github.com/software-mansion/react-native-reanimated/issues/6719) and aims to: - **Unify the method used to obtain the view tag**, as there are currently several approaches. - **Avoid passing a class component to the findNodeHandler**. Instead, we'll pass a ref to the component, similar to what Expo implemented here: [https://github.com/expo/expo/pull/33016](https://github.com/expo/expo/pull/33016). - **Limit unnecessary invocations of findNodeHandler** to no more than one call per render. - **Remove the invocation of findHostInstance from Paper renderer** on the New Architecture. **Additional Remarks:** - When a class component is passed to `createAnimatedComponent`, it will still fall back to the slow path where we can get a native ref. - In `NativeEventManager`, we need to call findNodeHandler again after every render to ensure that the children of `<GestureDetector />` haven't changed their native tags. - `LayoutAnimationConfig` still uses findNodeHandler. It requires a complete refactor of their functionality to eliminate its use, and I plan to handle this in another PR. - `findHostInstance_DEPRECATED` always follows the slow path even for native refs, which is why I've implemented our own version of `findHostInstance` to optimize the happy path. Fixes #6719 Related PRs: - #6030 - #5960 - #4445 - expo/expo#33016 ## Test plan - [x] check Paper - [x] check Fabric - [x] check Web
## Summary This PR addresses the issue reported at [https://github.com/software-mansion/react-native-reanimated/issues/6719](https://github.com/software-mansion/react-native-reanimated/issues/6719) and aims to: - **Unify the method used to obtain the view tag**, as there are currently several approaches. - **Avoid passing a class component to the findNodeHandler**. Instead, we'll pass a ref to the component, similar to what Expo implemented here: [https://github.com/expo/expo/pull/33016](https://github.com/expo/expo/pull/33016). - **Limit unnecessary invocations of findNodeHandler** to no more than one call per render. - **Remove the invocation of findHostInstance from Paper renderer** on the New Architecture. **Additional Remarks:** - When a class component is passed to `createAnimatedComponent`, it will still fall back to the slow path where we can get a native ref. - In `NativeEventManager`, we need to call findNodeHandler again after every render to ensure that the children of `<GestureDetector />` haven't changed their native tags. - `LayoutAnimationConfig` still uses findNodeHandler. It requires a complete refactor of their functionality to eliminate its use, and I plan to handle this in another PR. - `findHostInstance_DEPRECATED` always follows the slow path even for native refs, which is why I've implemented our own version of `findHostInstance` to optimize the happy path. Fixes #6719 Related PRs: - #6030 - #5960 - #4445 - expo/expo#33016 ## Test plan - [x] check Paper - [x] check Fabric - [x] check Web
Summary
This PR addresses the issue reported at #6719 and aims to:
Additional Remarks:
createAnimatedComponent
, it will still fall back to the slow path where we can get a native ref.NativeEventManager
, we need to call findNodeHandler again after every render to ensure that the children of<GestureDetector />
haven't changed their native tags.LayoutAnimationConfig
still uses findNodeHandler. It requires a complete refactor of their functionality to eliminate its use, and I plan to handle this in another PR.findHostInstance_DEPRECATED
always follows the slow path even for native refs, which is why I've implemented our own version offindHostInstance
to optimize the happy path.Fixes #6719
Related PRs:
Test plan