Search code examples
react-nativereact-native-reanimated-v2

Reanimated 2 animation entering/exiting withCallback error


If I use withCallback function on animation enter/exit or even when using the keyframe to create custom animation I get an error. Am I doing something wrong, or maybe missing something?

"react-native-reanimated": "^2.3.1",

<Animated.View
   entering={SlideInLeft.duration(animationDuration)}
   exiting={SlideOutRight.duration(animationDuration).withCallback(()=>{})}
>
   <View />
</Animated.View>

enter image description here


Solution

  • Fixed with

    const slideInLeft = SlideInLeft.withCallback((finished: boolean) => {
        'worklet';
        if (finished) {
         yourFoo(
        }
    });
    
    <Animated.View entering={slideInLeft} >
       ...
    </Animated.View>