Skip to content
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 relations not working when one of the child dependencies remounts without a render in the parent #3269

Merged
merged 3 commits into from
Dec 12, 2024

Conversation

j-piasecki
Copy link
Member

Description

Fixes #3265

As @gaearon pointed out in the issue:

I think what's happening here is that the library doesn't consider the fact that the contents of a ref can change over time without the parent knowing about it. Rather, it seems to be operating under assumption that a ref change at the bottom will always be accompanied by a state change near the top (wherever blocksExternalGesture is called).

That's unfortunately true, and the current API doesn't allow to use ref callbacks to handle this (nor would it be easy to update it to do that). This is one more point to the pile of reasons why the API needs an overhaul.

For the time being, I implemented a mechanism that allows GestureDetector to listen to the mounting and unmounting of gestures. This way it can react to a remount of a gesture it depends on and update the native side if necessary.

Test plan

Tested on the Example app and the reproducer from the issue

Android iOS
Screen.Recording.2024-12-09.at.12.23.28.mov
Screen.Recording.2024-12-09.at.12.14.50.mov

@j-piasecki j-piasecki requested review from latekvo, m-bert and tomekzaw and removed request for latekvo December 9, 2024 14:46
@j-piasecki j-piasecki merged commit d93bfe3 into main Dec 12, 2024
1 check passed
@j-piasecki j-piasecki deleted the @jpiasecki/fix-relations-on-remount branch December 12, 2024 11:47
@gaearon
Copy link

gaearon commented Jan 2, 2025

Would be great to start playing with it, can we get a canary release?

@j-piasecki
Copy link
Member Author

There's been a release candidate release a while ago - https://www.npmjs.com/package/react-native-gesture-handler/v/2.22.0-rc.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Conditional rendering breaks blocksExternalGesture
3 participants