diff --git a/packages/react-native-gesture-handler/src/v3/NativeDetector/HostGestureDetector.web.tsx b/packages/react-native-gesture-handler/src/v3/NativeDetector/HostGestureDetector.web.tsx index 46f0064574..fd096c9277 100644 --- a/packages/react-native-gesture-handler/src/v3/NativeDetector/HostGestureDetector.web.tsx +++ b/packages/react-native-gesture-handler/src/v3/NativeDetector/HostGestureDetector.web.tsx @@ -62,8 +62,8 @@ const HostGestureDetector = (props: GestureHandlerDetectorProps) => { }; useEffect(() => { - detachHandlers(attachedNativeHandlerTags.current); - }, [children]); + propsRef.current = props; + }, [props]); useEffect(() => { if (React.Children.count(children) !== 1) { @@ -72,14 +72,13 @@ const HostGestureDetector = (props: GestureHandlerDetectorProps) => { ); } - attachHandlers(new Set(handlerTags)); - }, [handlerTags, children]); + const newHandlerTags = new Set(handlerTags); + attachHandlers(newHandlerTags); - useEffect(() => { return () => { - detachHandlers(attachedHandlerTags.current); + detachHandlers(newHandlerTags); }; - }, []); + }, [handlerTags, children]); return ( }> diff --git a/packages/react-native-gesture-handler/src/v3/hooks/useGesture.ts b/packages/react-native-gesture-handler/src/v3/hooks/useGesture.ts index 1f58af928d..cec1f7dc18 100644 --- a/packages/react-native-gesture-handler/src/v3/hooks/useGesture.ts +++ b/packages/react-native-gesture-handler/src/v3/hooks/useGesture.ts @@ -94,6 +94,10 @@ export function useGesture( }, [type, tag]); useEffect(() => { + const preparedConfig = prepareConfig(config); + RNGestureHandlerModule.setGestureHandlerConfig(tag, preparedConfig); + RNGestureHandlerModule.flushOperations(); + bindSharedValues(config, tag); return () => { @@ -101,14 +105,6 @@ export function useGesture( }; }, [tag, config]); - useEffect(() => { - const preparedConfig = prepareConfig(config); - - RNGestureHandlerModule.setGestureHandlerConfig(tag, preparedConfig); - - RNGestureHandlerModule.flushOperations(); - }, [config, tag]); - return { tag, type,