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 ); }