Skip to content

Commit 349e799

Browse files
committed
Memo reanimated handlers
1 parent e510a5b commit 349e799

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

packages/react-native-gesture-handler/src/v3/detectors/VirtualDetector/InterceptingGestureDetector.tsx

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,14 +114,28 @@ export function InterceptingGestureDetector<THandlerData, TConfig>({
114114
[virtualChildren, gesture?.detectorCallbacks]
115115
);
116116

117+
const reanimatedUpdateEvents = useMemo(
118+
() => getHandlers('onReanimatedUpdateEvent'),
119+
[getHandlers]
120+
);
117121
const reanimatedEventHandler = Reanimated?.useComposedEventHandler(
118-
getHandlers('onReanimatedUpdateEvent')
122+
reanimatedUpdateEvents
123+
);
124+
125+
const reanimatedStateChangeEvents = useMemo(
126+
() => getHandlers('onReanimatedStateChange'),
127+
[getHandlers]
119128
);
120129
const reanimatedStateChangeHandler = Reanimated?.useComposedEventHandler(
121-
getHandlers('onReanimatedStateChange')
130+
reanimatedStateChangeEvents
131+
);
132+
133+
const reanimatedTouchEvents = useMemo(
134+
() => getHandlers('onReanimatedTouchEvent'),
135+
[getHandlers]
122136
);
123137
const reanimatedTouchEventHandler = Reanimated?.useComposedEventHandler(
124-
getHandlers('onReanimatedTouchEvent')
138+
reanimatedTouchEvents
125139
);
126140

127141
ensureNativeDetectorComponent(NativeDetectorComponent);

0 commit comments

Comments
 (0)