@@ -14,6 +14,7 @@ import {
1414} from 'react-native-reanimated'
1515import type { AnimationCallback , WithTimingConfig , SharedValue , AnimatableValue } from 'react-native-reanimated'
1616import { error , hasOwn , collectDataset } from '@mpxjs/utils'
17+ import { useRunOnJSCallback } from './utils'
1718import { ExtendedViewStyle } from './types/common'
1819import type { _ViewProps } from './mpx-view'
1920
@@ -218,13 +219,19 @@ export default function useAnimationHooks<T, P> (props: _ViewProps & { enableAni
218219 timeStamp : Date . now ( )
219220 } )
220221 }
222+ // eslint-disable-next-line react-hooks/rules-of-hooks
223+ const runOnJSCallbackRef = useRef ( {
224+ withTimingCallback
225+ } )
226+ // eslint-disable-next-line react-hooks/rules-of-hooks
227+ const runOnJSCallback = useRunOnJSCallback ( runOnJSCallbackRef )
221228 // 创建单个animation
222229 function getAnimation ( { key, value } : { key : string , value : string | number } , { delay, duration, easing } : ExtendWithTimingConfig , callback ?: AnimationCallback ) {
223230 const animation = typeof callback === 'function'
224231 ? withTiming ( value , { duration, easing } , ( finished , current ) => {
225232 callback ( finished , current )
226233 if ( transitionend && finished ) {
227- runOnJS ( withTimingCallback ) ( finished , current , duration )
234+ runOnJS ( runOnJSCallback ) ( 'withTimingCallback' , finished , current , duration )
228235 }
229236 } )
230237 : withTiming ( value , { duration, easing } )
0 commit comments