Complete the code to import the main hook from React Native Reanimated.
import [1] from 'react-native-reanimated';
The useSharedValue hook is the main way to create shared values in Reanimated.
Complete the code to create an animated style that changes opacity based on a shared value.
const animatedStyle = useAnimatedStyle(() => ({ opacity: [1].value }));The shared value variable (here named sharedValue) holds the animated number. We access its .value to get the current value.
Fix the error in the code to animate a view's translation on the X axis using withTiming.
sharedValue.value = [1](100);
useSharedValue instead of animation functions.withSpring when timing animation is needed.withTiming is used to animate a value smoothly to a target number over time.
Fill both blanks to create a shared value and an animated style that moves a view horizontally.
const [1] = useSharedValue(0); const animatedStyle = useAnimatedStyle(() => ({ transform: [{ translateX: [2].value }] }));
The shared value and the variable used in the animated style must have the same name to link the animation.
Fill all three blanks to create a gesture handler that updates a shared value on pan gesture.
const gestureHandler = useAnimatedGestureHandler({
onActive: (event) => {
[1].value = event.[2];
},
onEnd: () => {
[3].value = withTiming(0);
}
});translationX and translationY.translateX.The shared value is updated with the gesture's horizontal translation (translationX), and reset with withTiming.