-
-
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
Update view tag on componentDidUpdate
#4440
Conversation
componendDidUpdate
componentDidUpdate
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.
Everything looks ok 👍
Did you test it with other events and with a fast refresh also? According to git blame, this changes was introduced to fix refresh problem and memory leaks:
- 30cb355#diff-6d854e9ad2f5d0438ef94ce876c3a818a732927a8111955db1dea26105a4e7b1R122
- https://github.com/software-mansion/react-native-reanimated/blame/main/src/createAnimatedComponent.tsx#LL357C13-L357C43
Could you check if those changes don't break anything related to the above PR?
Could you attach the example source code to issue description?
@piaskowyk It looks that I've changed code from this PR: #3988, since I've modified how do we obtain viewTag. So I've tested that I am still able to fix attaching a scroll event if the scrollable component is not the root view |
@piaskowyk I've tested with refresh control, and measured time for old and new approach. It looks that the new one is two times faster 🚀 |
<!-- 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 <!-- Explain the motivation for this PR. Include "Fixes #<number>" if applicable. --> Fixes software-mansion#3769 Each time `componentDidUpdate` is triggered we have to subscribe for events again. However we used to use the same viewTag, although the viewTag may change each time the view is updated. This mean that the given view will stop receiving any events. Look at the above-linked issue to see the description of bug in the recordings. In the console you can see viewTag used to subscribe for events. In a buggy example it doesn't change when you modify the orientation of the scroll. <table> <tr><td>BEFORE</td><td> https://github.com/software-mansion/react-native-reanimated/assets/56199675/e8db724a-620f-4da1-ac44-bdc73e4d936b </td></tr> <tr><td>AFTER</td><td> https://github.com/software-mansion/react-native-reanimated/assets/56199675/b2a8d2c1-0476-4ddf-b543-b7c0b768389e </td></tr> </table> ## Test plan <!-- Provide a minimal but complete code snippet that can be used to test out this change along with instructions how to run it and a description of the expected behavior. --> Tested on example from the issue: https://snack.expo.dev/fTGYvJ2t5 Co-authored-by: Aleksandra Cynk <aleksandracynk@swmansion.com>
Summary
Fixes #3769
Each time
componentDidUpdate
is triggered we have to subscribe for events again. However we used to use the same viewTag, although the viewTag may change each time the view is updated. This mean that the given view will stop receiving any events.Look at the above-linked issue to see the description of bug in the recordings. In the console you can see viewTag used to subscribe for events. In a buggy example it doesn't change when you modify the orientation of the scroll.
Screen.Recording.2023-05-09.at.12.31.53.mov
Screen.Recording.2023-05-09.at.12.32.28.mov
Test plan
Tested on example from the issue: https://snack.expo.dev/fTGYvJ2t5