Skip to content

Commit d20ee86

Browse files
authored
Fix old Gesture Handler API integration with Reaniamted (#2881)
## Description This PR resolves the recognition issue of the Reanimated Event handler for the previous Gesture Handler API. This adjustment was necessary due to a modification in the internal property name that was utilized to identify the Reanimated event handler (as seen here: software-mansion/react-native-reanimated#5743). ## Test plan Run this example - https://github.com/software-mansion/react-native-reanimated/blob/main/app/src/examples/DragAndSnapExample.tsx
1 parent fc244ff commit d20ee86

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

src/handlers/createHandler.tsx

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -341,18 +341,22 @@ export default function createHandler<
341341
});
342342

343343
const actionType = (() => {
344-
if (
345-
(this.props?.onGestureEvent &&
346-
'current' in this.props.onGestureEvent) ||
347-
(this.props?.onHandlerStateChange &&
348-
'current' in this.props.onHandlerStateChange)
349-
) {
344+
const onGestureEvent = this.props?.onGestureEvent;
345+
const isGestureHandlerWorklet =
346+
onGestureEvent &&
347+
('current' in onGestureEvent ||
348+
'workletEventHandler' in onGestureEvent);
349+
const onHandlerStateChange = this.props?.onHandlerStateChange;
350+
const isStateChangeHandlerWorklet =
351+
onHandlerStateChange &&
352+
('current' in onHandlerStateChange ||
353+
'workletEventHandler' in onHandlerStateChange);
354+
const isReanimatedHandler =
355+
isGestureHandlerWorklet || isStateChangeHandlerWorklet;
356+
if (isReanimatedHandler) {
350357
// Reanimated worklet
351358
return ActionType.REANIMATED_WORKLET;
352-
} else if (
353-
this.props?.onGestureEvent &&
354-
'__isNative' in this.props.onGestureEvent
355-
) {
359+
} else if (onGestureEvent && '__isNative' in onGestureEvent) {
356360
// Animated.event with useNativeDriver: true
357361
return ActionType.NATIVE_ANIMATED_EVENT;
358362
} else {

0 commit comments

Comments
 (0)