Skip to content

Commit d157b24

Browse files
committed
Move reusing gestures to redbox
1 parent bc735eb commit d157b24

1 file changed

Lines changed: 8 additions & 28 deletions

File tree

packages/docs-gesture-handler/docs/fundamentals/gesture-detector.mdx

Lines changed: 8 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,16 @@ import CollapsibleCode from '@site/src/components/CollapsibleCode';
1212

1313
The `GestureDetector` is a key component of RNGH3. It supports gestures created either using the hooks API or the builder pattern. Additionally, it allows for the recognition of multiple gestures through [gesture composition](/docs/fundamentals/gesture-composition). `GestureDetector` interacts closely with [`Reanimated`](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/getting-started/). For more details, refer to the [Integration with Reanimated](/docs/fundamentals/reanimated-interactions) section.
1414

15-
When using hook API, you can also integrate it directly with the [Animated API](https://reactnative.dev/docs/animated).
15+
When using hook API, you can also integrate it directly with the [Animated API](https://reactnative.dev/docs/animated). More on that can be found in [Integreation with Animated](/docs/fundamentals/animated-interactions) section.
16+
17+
:::danger
18+
19+
#### Nesting Gesture Detectors
1620

17-
:::danger Nesting Gesture Detectors
1821
Because `GestureDetector` supports both the hook API and the builder pattern, it is important to avoid nesting detectors that use different APIs, as this can result in unexpected behavior.
22+
23+
#### Reusing Gestures
24+
Using the same instance of a gesture across multiple Gesture Detectors may result in unexpected behavior.
1925
:::
2026

2127
```js
@@ -216,29 +222,3 @@ enableContextMenu: boolean;
216222
```
217223

218224
Specifies whether context menu should be enabled after clicking on underlying view with right mouse button. Default value is set to `false`.
219-
220-
## Remarks
221-
222-
- Using the same instance of a gesture across multiple Gesture Detectors is not possible. Have a look at the code below:
223-
224-
```jsx
225-
export default function Example() {
226-
const pan = usePanGesture({});
227-
228-
return (
229-
<View>
230-
// highlight-next-line
231-
<GestureDetector gesture={pan}>
232-
<View>
233-
// highlight-next-line
234-
<GestureDetector gesture={pan}>
235-
<View />
236-
</GestureDetector>
237-
</View>
238-
</GestureDetector>
239-
</View>
240-
);
241-
}
242-
```
243-
244-
This example will throw an error, because the same instance of `Pan` is being used in two different Gesture Detectors.

0 commit comments

Comments
 (0)