From 71d7d46a5e19bd6b84260e227f0560f7f57147dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82?= Date: Tue, 14 Oct 2025 12:56:43 +0200 Subject: [PATCH 1/3] Check worklets only for callbacks --- .../react-native-gesture-handler/src/v3/hooks/utils.ts | 10 ++++++++-- .../src/v3/hooks/utils/reanimatedUtils.ts | 9 +++++++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/packages/react-native-gesture-handler/src/v3/hooks/utils.ts b/packages/react-native-gesture-handler/src/v3/hooks/utils.ts index bfff3971fe..b2dbbde081 100644 --- a/packages/react-native-gesture-handler/src/v3/hooks/utils.ts +++ b/packages/react-native-gesture-handler/src/v3/hooks/utils.ts @@ -14,6 +14,7 @@ import { SingleGestureName, InternalConfigProps, HandlersPropsWhiteList, + GestureCallbacks, } from '../types'; import { GestureTouchEvent } from '../../handlers/gestureHandlerCommon'; import { tagMessage } from '../../utils'; @@ -110,8 +111,9 @@ const allowedNativeProps = new Set< 'changeEventCalculator', ]); -const PropsToFilter = new Set>([ - // Callbacks +export const HandlerCallbacks = new Set< + keyof Required> +>([ 'onBegin', 'onStart', 'onUpdate', @@ -121,6 +123,10 @@ const PropsToFilter = new Set>([ 'onTouchesMove', 'onTouchesUp', 'onTouchesCancelled', +]); + +const PropsToFilter = new Set>([ + ...HandlerCallbacks, // Config props 'changeEventCalculator', diff --git a/packages/react-native-gesture-handler/src/v3/hooks/utils/reanimatedUtils.ts b/packages/react-native-gesture-handler/src/v3/hooks/utils/reanimatedUtils.ts index 1cd7929a60..e80a8092a0 100644 --- a/packages/react-native-gesture-handler/src/v3/hooks/utils/reanimatedUtils.ts +++ b/packages/react-native-gesture-handler/src/v3/hooks/utils/reanimatedUtils.ts @@ -1,6 +1,7 @@ import RNGestureHandlerModule from '../../../RNGestureHandlerModule'; import { Reanimated } from '../../../handlers/gestures/reanimatedWrapper'; import { BaseGestureConfig, SharedValue } from '../../types'; +import { HandlerCallbacks } from '../utils'; // Variant of djb2 hash function. // Taken from https://gist.github.com/eplawless/52813b1d8ad9af510d85?permalink_comment_id=3367765#gistcomment-3367765 @@ -77,7 +78,11 @@ export function unbindSharedValues( export function hasWorkletEventHandlers( config: BaseGestureConfig ) { - return Object.values(config).some( - (prop) => typeof prop === 'function' && '__workletHash' in prop + return Object.entries(config).some( + (key, value) => + (key as keyof BaseGestureConfig) in + HandlerCallbacks && + typeof value === 'function' && + '__workletHash' in value ); } From 34180294df6077af36bc02e690009df7770f4761 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82?= Date: Tue, 14 Oct 2025 12:57:01 +0200 Subject: [PATCH 2/3] Do not use handleGestureEvent for Animated.Event --- .../src/v3/NativeDetector/NativeDetector.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/react-native-gesture-handler/src/v3/NativeDetector/NativeDetector.tsx b/packages/react-native-gesture-handler/src/v3/NativeDetector/NativeDetector.tsx index 6bd6b3a120..ea2f73e40b 100644 --- a/packages/react-native-gesture-handler/src/v3/NativeDetector/NativeDetector.tsx +++ b/packages/react-native-gesture-handler/src/v3/NativeDetector/NativeDetector.tsx @@ -135,9 +135,9 @@ export function NativeDetector({ // @ts-ignore This is a type mismatch between RNGH types and RN Codegen types onGestureHandlerEvent={handleGestureEvent('onGestureHandlerEvent')} // @ts-ignore This is a type mismatch between RNGH types and RN Codegen types - onGestureHandlerAnimatedEvent={handleGestureEvent( - 'onGestureHandlerAnimatedEvent' - )} + onGestureHandlerAnimatedEvent={ + gesture.gestureEvents.onGestureHandlerAnimatedEvent + } // @ts-ignore This is a type mismatch between RNGH types and RN Codegen types onGestureHandlerTouchEvent={handleGestureEvent( 'onGestureHandlerTouchEvent' From 678469172babfabad6cd86b8472c09e80fc4e45e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82?= Date: Tue, 14 Oct 2025 15:55:21 +0200 Subject: [PATCH 3/3] Revert "Do not use handleGestureEvent for Animated.Event" This reverts commit 34180294df6077af36bc02e690009df7770f4761. --- .../src/v3/NativeDetector/NativeDetector.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/react-native-gesture-handler/src/v3/NativeDetector/NativeDetector.tsx b/packages/react-native-gesture-handler/src/v3/NativeDetector/NativeDetector.tsx index ea2f73e40b..6bd6b3a120 100644 --- a/packages/react-native-gesture-handler/src/v3/NativeDetector/NativeDetector.tsx +++ b/packages/react-native-gesture-handler/src/v3/NativeDetector/NativeDetector.tsx @@ -135,9 +135,9 @@ export function NativeDetector({ // @ts-ignore This is a type mismatch between RNGH types and RN Codegen types onGestureHandlerEvent={handleGestureEvent('onGestureHandlerEvent')} // @ts-ignore This is a type mismatch between RNGH types and RN Codegen types - onGestureHandlerAnimatedEvent={ - gesture.gestureEvents.onGestureHandlerAnimatedEvent - } + onGestureHandlerAnimatedEvent={handleGestureEvent( + 'onGestureHandlerAnimatedEvent' + )} // @ts-ignore This is a type mismatch between RNGH types and RN Codegen types onGestureHandlerTouchEvent={handleGestureEvent( 'onGestureHandlerTouchEvent'