-
-
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
Fix animatedRef on Fabric #4445
Conversation
Does it mean that |
Co-authored-by: Tomek Zawadzki <tomasz.zawadzki@swmansion.com>
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.
We need add some comments here, and table with information about which method is used by ScrollView, FlatList and FlashList
console.warn( | ||
`[Reanimated] ${ | ||
component.displayName || component.name || 'Component' | ||
} has no implemented 'getNativeScrollRef' method. Please report this issue to the library maintainers.` | ||
); | ||
} |
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.
We need to remove this config because we can pass here reference to any object.
@@ -19,6 +22,25 @@ function getShareableShadowNodeFromComponent( | |||
return getShadowNodeWrapperFromHostInstance(component); | |||
} | |||
|
|||
function getScrollableRef(component: ComponentRef): ComponentRef { |
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.
getScrollableRef -> getComponentRef
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.
getComponentRef
is too generic I think
Co-authored-by: Tomek Zawadzki <tomasz.zawadzki@swmansion.com>
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.
👏
<!-- Thanks for submitting a pull request! We appreciate you spending the time to work on these changes. Please follow the template so that the reviewers can easily understand what the code changes affect. --> ## Summary - Fixes software-mansion#4256 ### Problem If the scrollable component is not root, UI `scrollTo` doesn't work on Fabric. software-mansion#4384 - It was fixed here for Paper, but after this change app crashes on Fabric, because `getScrollableNode` in both architectures returns viewTag as a number, not component. It's working for Paper, because we are passing either component or number to `findNodeHandle` method, but on Fabric we need component ref. ### Fix Instead of `getScrollableNode`, we can use `getNativeScrollRef` and get scrollable reference. ### TODO Unfortunately this method is not implemented yet for `Flash-list` -> https://shopify.github.io/flash-list/docs/usage#:~:text=Unsupported%20methods%3A so for now, UI `scrollTo` on FlashList works only for Paper Architecture. ## Test plan ScrollToExample: - Paper, ScrollView - Paper, FlatList - Fabric, ScrollView - Fabric, FlatList --------- Co-authored-by: Tomek Zawadzki <tomasz.zawadzki@swmansion.com>
## 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 [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
Problem
If the scrollable component is not root, UI
scrollTo
doesn't work on Fabric.#4384 - It was fixed here for Paper, but after this change app crashes on Fabric, because
getScrollableNode
in both architectures returns viewTag as a number, not component. It's working for Paper, because we are passing either component or number tofindNodeHandle
method, but on Fabric we need component ref.Fix
Instead of
getScrollableNode
, we can usegetNativeScrollRef
and get scrollable reference.TODO
Unfortunately this method is not implemented yet for
Flash-list
-> https://shopify.github.io/flash-list/docs/usage#:~:text=Unsupported%20methods%3Aso for now, UI
scrollTo
on FlashList works only for Paper Architecture.Test plan
ScrollToExample: