@@ -13,6 +13,7 @@ import { Animated, StyleSheet } from 'react-native';
13
13
import HostGestureDetector from './HostGestureDetector' ;
14
14
import { tagMessage } from '../utils' ;
15
15
import { LogicDetectorProps } from './LogicDetector' ;
16
+ import { runOnJS } from 'react-native-reanimated' ;
16
17
17
18
export interface NativeDetectorProps {
18
19
children ?: React . ReactNode ;
@@ -94,21 +95,27 @@ export function NativeDetector({ gesture, children }: NativeDetectorProps) {
94
95
gesture . gestureEvents . onGestureHandlerTouchEvent
95
96
}
96
97
onGestureHandlerLogicEvent = { ( e ) => {
97
- logicMethods . current
98
- . get ( e . nativeEvent . childTag )
99
- ?. onGestureHandlerEvent ( e ) ;
98
+ const logicMethod = logicMethods . current . get (
99
+ e . nativeEvent . childTag
100
+ ) ?. onGestureHandlerEvent ;
101
+ if ( logicMethod ) {
102
+ runOnJS ( logicMethod ) ;
103
+ }
100
104
} }
101
105
onGestureHandlerLogicStateChange = { ( e ) => {
102
- logicMethods . current
103
- . get ( e . nativeEvent . childTag )
104
- ?. onGestureHandlerStateChange ( e ) ;
106
+ const logicMethod = logicMethods . current . get (
107
+ e . nativeEvent . childTag
108
+ ) ?. onGestureHandlerStateChange ;
109
+ if ( logicMethod ) {
110
+ runOnJS ( logicMethod ) ;
111
+ }
105
112
} }
106
113
onGestureHandlerLogicTouchEvent = { ( e ) => {
107
- const touchEvent = logicMethods . current . get (
114
+ const logicMethod = logicMethods . current . get (
108
115
e . nativeEvent . childTag
109
116
) ?. onGestureHandlerTouchEvent ;
110
- if ( touchEvent ) {
111
- touchEvent ( e ) ;
117
+ if ( logicMethod ) {
118
+ runOnJS ( logicMethod ) ;
112
119
}
113
120
} }
114
121
moduleId = { globalThis . _RNGH_MODULE_ID }
0 commit comments