Skip to content

Commit 968112c

Browse files
committed
better useffect triggers:
1 parent 32fea07 commit 968112c

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

packages/react-native-gesture-handler/src/web/detectors/GestureHandlerDetector.tsx

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,34 @@ export interface GestureHandlerDetectorProps extends ViewProps {
1717
dispatchesAnimatedEvents: boolean;
1818
moduleId: number;
1919
}
20+
2021
const GestureHandlerDetector = (props: GestureHandlerDetectorProps) => {
21-
const { handlerTags } = props;
22+
const {
23+
onGestureHandlerEvent,
24+
onGestureHandlerAnimatedEvent,
25+
onGestureHandlerStateChange,
26+
onGestureHandlerTouchEvent,
27+
handlerTags,
28+
dispatchesAnimatedEvents,
29+
moduleId,
30+
} = props;
2231

2332
const viewRef = useRef(null);
2433
const propsRef = useRef<GestureHandlerDetectorProps>(props);
2534

2635
useEffect(() => {
27-
updateProps();
28-
}, [props]);
36+
attachHandlers();
37+
}, [
38+
onGestureHandlerEvent,
39+
onGestureHandlerAnimatedEvent,
40+
onGestureHandlerStateChange,
41+
onGestureHandlerTouchEvent,
42+
handlerTags,
43+
dispatchesAnimatedEvents,
44+
moduleId,
45+
]);
2946

30-
const updateProps = (): void => {
47+
const attachHandlers = (): void => {
3148
handlerTags.forEach((tag) => {
3249
RNGestureHandlerModuleWeb.attachGestureHandler(
3350
tag,
@@ -39,4 +56,5 @@ const GestureHandlerDetector = (props: GestureHandlerDetectorProps) => {
3956
};
4057
return <View ref={viewRef}>{props.children}</View>;
4158
};
59+
4260
export default GestureHandlerDetector;

0 commit comments

Comments
 (0)