-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Change components implementation #3800
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
Merged
Merged
+1,654
−488
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
m-bert
added a commit
that referenced
this pull request
Nov 17, 2025
## What is happening While working on #3800 I've noticed frequent crashes on `iOS`. I'll explain this using the demo from the test code, basically two screens, second screen has a `RectButton`. 1. Navigate to second screen 2. Go back 3. Navigate to the second screen again 4. App crashes Sometime it crashes immediately on startup. ## Why is it happening? `Native` handlers are handled differently compared to others. The main problem was that we tried to attach handler that was previously dropped, but `NativeDetector` has no information that this happened. The flow here looks as follows: 1. We navigate to screen with button 2. `addSubview` is called - at this point it won't attach anything as `_nativeHandlers` is empty 3. `updateProps` is called - handlers are attached 4. We navigate back to first screen 5. Handler is dropped 6. We navigate again to second screen 7. `addSubview` is called - it tries to attach handler that was dropped, therefore app crashes ## Solution To fix this issue, we clear `_nativeHandlers` in `prepareForRecycle` method. ## Test plan <details> <summary>I've tested it on my branch with components re-written to new API, using the following code in EmptyExample:</summary> ```tsx import React from 'react'; import { StyleSheet, View } from 'react-native'; import { RectButton } from 'react-native-gesture-handler'; export default function EmptyExample() { return ( <View style={styles.container}> <RectButton style={styles.button} onPress={() => console.log('Hello World!')} /> </View> ); } const styles = StyleSheet.create({ container: { flex: 1, justifyContent: 'center', alignItems: 'center', }, button: { width: 100, height: 30, borderRadius: 10, backgroundColor: 'pink', }, }); ``` </details>
j-piasecki
reviewed
Nov 26, 2025
...ve-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/core/GestureHandler.kt
Outdated
Show resolved
Hide resolved
...ler/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerDetectorView.kt
Show resolved
Hide resolved
packages/react-native-gesture-handler/src/web/tools/GestureHandlerWebDelegate.ts
Show resolved
Hide resolved
packages/react-native-gesture-handler/src/v3/components/GestureComponents.tsx
Outdated
Show resolved
Hide resolved
packages/react-native-gesture-handler/src/v3/components/GestureComponents.tsx
Outdated
Show resolved
Hide resolved
packages/react-native-gesture-handler/src/v3/components/GestureComponents.tsx
Show resolved
Hide resolved
…eComponents.tsx Co-authored-by: Jakub Piasecki <jakub.piasecki@swmansion.com>
j-piasecki
reviewed
Nov 27, 2025
...ler/android/src/main/java/com/swmansion/gesturehandler/react/events/RNGestureHandlerEvent.kt
Outdated
Show resolved
Hide resolved
j-piasecki
reviewed
Nov 28, 2025
packages/react-native-gesture-handler/src/v3/components/GestureComponents.tsx
Outdated
Show resolved
Hide resolved
...ler/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerDetectorView.kt
Show resolved
Hide resolved
packages/react-native-gesture-handler/src/components/GestureComponents.tsx
Show resolved
Hide resolved
j-piasecki
reviewed
Nov 28, 2025
packages/react-native-gesture-handler/src/v3/createNativeWrapper.tsx
Outdated
Show resolved
Hide resolved
j-piasecki
reviewed
Dec 2, 2025
packages/react-native-gesture-handler/src/v3/createNativeWrapper.tsx
Outdated
Show resolved
Hide resolved
packages/react-native-gesture-handler/src/v3/createNativeWrapper.tsx
Outdated
Show resolved
Hide resolved
j-piasecki
approved these changes
Dec 2, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR changes components implementations to use new hooks API.
Warning
It requires changes in module on iOS - call
createGestureHandlerimmediately, not adding operation block.Test plan
Example apps