-
-
Notifications
You must be signed in to change notification settings - Fork 981
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove event listeners on handler drop (#2815)
## Description Right now when handlers are dropped, event listeners are not removed from view. I think this might cause problems with SSR. With this PR, listeners are properly removed from underlying view. ### Before https://github.com/software-mansion/react-native-gesture-handler/assets/63123542/e676a513-d505-41db-b302-96538d585c70 ### After https://github.com/software-mansion/react-native-gesture-handler/assets/63123542/5aa8a319-17c4-4ca5-9f44-bbc60b6d0fe3 ## Test plan 1. Run the following code: <details> <summary>Test code</summary> ```jsx import React, { useState } from 'react'; import { StyleSheet, View } from 'react-native'; import { Gesture, GestureDetector } from 'react-native-gesture-handler'; export default function EmptyExample() { const fling = Gesture.Fling(); const tap = Gesture.Tap(); const [g, setG] = useState<any>(fling); setTimeout(() => { setG(tap); console.log('Switching gesture to tap'); }, 1500); return ( <View style={styles.container}> <GestureDetector gesture={g}> <View style={[styles.circle, { backgroundColor: 'crimson' }]} /> </GestureDetector> </View> ); } const styles = StyleSheet.create({ container: { flex: 1, justifyContent: 'center', alignItems: 'center', }, circle: { width: 150, height: 150, borderRadius: 75, }, }); ``` </details> 2. Select red circle with inspector and navigate to `Event Listeners` 3. Check that only one listener is present after `Gesture` was changed
- Loading branch information
Showing
7 changed files
with
335 additions
and
299 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.