Challenge - 5 Problems
Reanimated Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ ui_behavior
intermediate2:00remaining
What is the output of this Reanimated shared value update?
Consider this React Native Reanimated code snippet that updates a shared value on button press. What will be the value of
progress.value after pressing the button twice?React Native
import {useSharedValue} from 'react-native-reanimated'; const progress = useSharedValue(0); function onPress() { progress.value = progress.value + 0.5; }
Attempts:
2 left
💡 Hint
Each press adds 0.5 to the current value.
✗ Incorrect
The shared value starts at 0. Each press adds 0.5, so after two presses, progress.value is 1.0.
❓ lifecycle
intermediate2:00remaining
When does a worklet run in React Native Reanimated?
In React Native Reanimated, when is a worklet function executed?
Attempts:
2 left
💡 Hint
Worklets run on the UI thread for smooth animations.
✗ Incorrect
Worklets are special functions that run on the UI thread, scheduled by Reanimated to avoid blocking the JS thread.
📝 Syntax
advanced2:00remaining
What error does this Reanimated code produce?
What error will this code snippet cause when run in a React Native app using Reanimated?
React Native
import {useSharedValue} from 'react-native-reanimated'; const progress = useSharedValue(0); function update() { 'worklet'; progress.value += 1; } update();
Attempts:
2 left
💡 Hint
Worklets have isolated scope and cannot access variables outside unless passed or declared.
✗ Incorrect
Inside a worklet, variables from outside scope are not accessible unless passed explicitly. Here, progress is undefined inside the worklet.
advanced
2:00remaining
How to trigger a navigation action after animation ends?
You want to navigate to another screen after a Reanimated animation finishes. Which approach correctly triggers navigation after the animation?
Attempts:
2 left
💡 Hint
Navigation functions run on JS thread, so use runOnJS to call them from worklet.
✗ Incorrect
Animation callbacks run on UI thread worklets. To call JS thread functions like navigation, use runOnJS inside the animation callback.
🧠 Conceptual
expert2:00remaining
What is the main benefit of using React Native Reanimated worklets?
Why do React Native developers use worklets in Reanimated for animations instead of running animation logic on the JS thread?
Attempts:
2 left
💡 Hint
Think about what causes janky animations in React Native.
✗ Incorrect
Worklets run animation code on the UI thread, avoiding delays caused by JS thread blocking, resulting in smooth animations.