Skip to content

Commit

Permalink
Fix old Gesture Handler API integration with Reaniamted (#2881)
Browse files Browse the repository at this point in the history
## 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
  • Loading branch information
piaskowyk committed Apr 29, 2024
1 parent fc244ff commit d20ee86
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions src/handlers/createHandler.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -341,18 +341,22 @@ export default function createHandler<
});

const actionType = (() => {
if (
(this.props?.onGestureEvent &&
'current' in this.props.onGestureEvent) ||
(this.props?.onHandlerStateChange &&
'current' in this.props.onHandlerStateChange)
) {
const onGestureEvent = this.props?.onGestureEvent;
const isGestureHandlerWorklet =
onGestureEvent &&
('current' in onGestureEvent ||
'workletEventHandler' in onGestureEvent);
const onHandlerStateChange = this.props?.onHandlerStateChange;
const isStateChangeHandlerWorklet =
onHandlerStateChange &&
('current' in onHandlerStateChange ||
'workletEventHandler' in onHandlerStateChange);
const isReanimatedHandler =
isGestureHandlerWorklet || isStateChangeHandlerWorklet;
if (isReanimatedHandler) {
// Reanimated worklet
return ActionType.REANIMATED_WORKLET;
} else if (
this.props?.onGestureEvent &&
'__isNative' in this.props.onGestureEvent
) {
} else if (onGestureEvent && '__isNative' in onGestureEvent) {
// Animated.event with useNativeDriver: true
return ActionType.NATIVE_ANIMATED_EVENT;
} else {
Expand Down

0 comments on commit d20ee86

Please sign in to comment.