File tree Expand file tree Collapse file tree
packages/docs-gesture-handler/docs/components Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -60,6 +60,25 @@ Components listed below come with a pre-applied `Native` gesture.
6060
6161:::danger
6262This callback may lead to infinite re-renders if not used carefully.
63+
64+ ``` tsx
65+ export default function App() {
66+ const [gesture, setGesture] = useState <NativeGesture | null >(null );
67+
68+ const updateGesture = (g : NativeGesture ) => {
69+ // ❌ Wrong usage: calling setState here triggers a re-render,
70+ // which re-creates the ScrollView's Native gesture, which fires
71+ // this callback again → infinite re-render loop.
72+ setGesture (g );
73+ };
74+
75+ return (
76+ <GestureHandlerRootView style = { { flex: 1 }} >
77+ <ScrollView onGestureUpdate_CAN_CAUSE_INFINITE_RERENDER = { updateGesture } />
78+ </GestureHandlerRootView >
79+ );
80+ }
81+ ```
6382:::
6483
6584Those components also receive an additional prop named ` onGestureUpdate_CAN_CAUSE_INFINITE_RERENDER ` .
You can’t perform that action at this time.
0 commit comments