I am working with react native reanimated 2
To make animations with opacity
This example works as well
const width = useSharedValue(50);
const animatedStyle = useAnimatedStyle(() => {
return {
opacity: width.value,
};
});
return <Animated.View style={[styles.box, animatedStyle]} />;
But when I want to calculate any value that does not work
I get an error
const width = useSharedValue(50);
const animatedStyle = useAnimatedStyle(() => {
return {
opacity: cond(greaterThan(width.value, 10), 1, 0),
};
});
return <Animated.View style={[styles.box, animatedStyle]} />;
I get errors like that
cannot read property 'onFrame' on null
How can I calculate the value in 'useAmimationStyle'?