Commit ad2029d
authored
Throw error when detectors are not placed inside
## Description
For now, `NativeDetector` doesn't throw error when it is used outside of
`GestureHandlerRootView`. This PR moves check from `LegacyDetector` to
`GestureDetector`.
## Test plan
<details>
<summary>Tested on the following example:</summary>
```tsx
import React from 'react';
import { StyleSheet, View } from 'react-native';
import { usePan, GestureDetector } from 'react-native-gesture-handler';
export default function EmptyExample() {
const pan = usePan({});
return (
<View style={styles.container}>
<GestureDetector gesture={pan}>
<View style={{ width: 300, height: 300, backgroundColor: 'green' }} />
</GestureDetector>
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
},
});
```
</details>GestureHandlerRootView (#3798)1 parent 76caf44 commit ad2029d
File tree
2 files changed
+12
-12
lines changed- packages/react-native-gesture-handler/src
- handlers/gestures/GestureDetector
- v3/detectors
2 files changed
+12
-12
lines changedLines changed: 1 addition & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
3 | | - | |
| 2 | + | |
4 | 3 | | |
5 | 4 | | |
6 | 5 | | |
7 | 6 | | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | 7 | | |
12 | 8 | | |
13 | 9 | | |
| |||
87 | 83 | | |
88 | 84 | | |
89 | 85 | | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | 86 | | |
98 | 87 | | |
99 | 88 | | |
| |||
Lines changed: 11 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
12 | 15 | | |
13 | 16 | | |
14 | 17 | | |
15 | 18 | | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
16 | 27 | | |
17 | 28 | | |
18 | 29 | | |
| |||
0 commit comments