-
-
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.
Add checks for the same instance of handler usage across multiple `Ge…
…stureDetectors` (#2694) ## Description Some of our users incorrectly use gesture handlers - they pass the same gesture handler instance into multiple `GestureDetectors`. It very often leads to unexpected behavior, like described in #2688. Currently web version of our library throws error `Handler with tag x already exists`. However, there are 2 problems with that: 1. This error message is not really helpful in case of fixing that problem. 2. Native platforms do not perform this check, so people don't know that they're using our handlers in a wrong way. This PR: - Improves error message - Adds check on native platforms - Adds information about error in `GestureDetector` documentation in remarks section ## Test plan Tested with code below on all platforms. <details> <summary>Code that throws error</summary> ```jsx import React from 'react'; import { View } from 'react-native'; import { Gesture, GestureDetector } from 'react-native-gesture-handler'; export default function Example() { const pan = Gesture.Pan(); return ( <View> <GestureDetector gesture={pan}> <View> <GestureDetector gesture={pan}> <View /> </GestureDetector> </View> </GestureDetector> </View> ); } ``` </details>
- Loading branch information
Showing
4 changed files
with
40 additions
and
1 deletion.
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