react-native-reanimated: Can't cast NoopNode to ClockNode on Android
I use animation function, which is defined as follows:
const animateTranslation = (
clock: Animated.Clock,
position: Animated.Value<number>,
translation: Animated.Value<number>,
offset: Animated.Value<number>,
min: Animated.Value<number>,
max: Animated.Value<number>,
gestureState: Animated.Value<State>
) => {
const snapPoint = new Value(0);
const myclock = new Clock();
return cond(clockRunning(myclock), snapPoint, snapPoint);
};
and later use the returned value to animate Animated.View's
property:
const taskTranslateY = animateTranslation(clock, position, translationY, offsetY, min, max, state);
...
<Animated.View
style={{
flex: 1,
flexDirection: 'column',
marginTop: -200,
transform: [{ translateY: taskTranslateY }]
}}
>
...
</Animated.View>
And I started getting this error, which I can’t understand or somehow to deal with. Where is a bug?
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 17 (8 by maintainers)
I add a cond block to check whether the clock is defined. and it worked for me
I’m having the same issue, clock is basically unusable on android, Basically anything I do with clock will trigger the same issue. Using 1.7.0
EDIT: For us, it turns out that we were using spring, and within state, we didn’t define velocity. So the error message is a bit misleading. If you run into this problem, I recommend that you double and triple check your state and config for the animation, see if that can fix your problem.
I did have this very issue but with different settings.
I was starting an animation with different lengths depending on the
pressed
state of aPressable
so the button scales instantly onpressDown
and animates onpressUp
.It worked on iOS but crashes with the error Can’t cast NoopNode to ClockNode on Android.
The fix I applied was to put an animation length greater than zero.
Hope this can help someone ✨
@jakub-gonet I didn’t get the error for your code but I replaced the return part with the below, I was able to reproduce it.
@luogao Thanks, you solved my problem…
@pearup Timing doesn’t have velocity. Where do you define velocity?