0
0
React Nativemobile~10 mins

Animated.Value and Animated.timing in React Native - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a new animated value starting at 0.

React Native
const opacity = new Animated.[1](0);
Drag options to blanks, or click blank then click option'
AValue
Btiming
Cspring
Dsequence
Attempts:
3 left
💡 Hint
Common Mistakes
Using Animated.timing instead of Animated.Value to create the value.
Trying to call Animated.Value as a function without 'new'.
2fill in blank
medium

Complete the code to animate the opacity value to 1 over 500 milliseconds.

React Native
Animated.[1](opacity, { toValue: 1, duration: 500 }).start();
Drag options to blanks, or click blank then click option'
Aspring
Btiming
Cdecay
Dloop
Attempts:
3 left
💡 Hint
Common Mistakes
Using Animated.spring instead of Animated.timing for duration-based animation.
Forgetting to call .start() to begin the animation.
3fill in blank
hard

Fix the error in the code to properly animate the value.

React Native
Animated.timing([1], { toValue: 100, duration: 300 }).start();
Drag options to blanks, or click blank then click option'
Aopacity
B100
Cduration
DAnimated.Value
Attempts:
3 left
💡 Hint
Common Mistakes
Passing a number instead of the animated value.
Passing the string 'duration' or 'Animated.Value' instead of the variable.
4fill in blank
hard

Fill both blanks to create an animated style that changes opacity using the animated value.

React Native
const animatedStyle = { opacity: [1] }; 
<View style={ [2] }></View>
Drag options to blanks, or click blank then click option'
Aopacity
BanimatedStyle
C{animatedStyle}
Dstyle
Attempts:
3 left
💡 Hint
Common Mistakes
Wrapping the style variable in extra curly braces like {animatedStyle} in JSX.
Using a string instead of the animated value for opacity.
5fill in blank
hard

Fill all three blanks to create and start an animation that moves a view horizontally from 0 to 150 over 700ms.

React Native
const translateX = new Animated.[1](0);
Animated.[2](translateX, { toValue: [3], duration: 700 }).start();
Drag options to blanks, or click blank then click option'
AValue
Btiming
C150
D300
Attempts:
3 left
💡 Hint
Common Mistakes
Using Animated.spring instead of Animated.timing.
Setting toValue to 300 instead of 150.
Forgetting to call .start() to begin animation.