0
0
React Nativemobile~20 mins

React Native Reanimated - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Reanimated Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
ui_behavior
intermediate
2: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;
}
A1.0
B0.5
C2.0
D0
Attempts:
2 left
💡 Hint
Each press adds 0.5 to the current value.
lifecycle
intermediate
2:00remaining
When does a worklet run in React Native Reanimated?
In React Native Reanimated, when is a worklet function executed?
AOn the UI thread, immediately when called from JS thread
BOn the UI thread, scheduled by Reanimated runtime
COnly on the JS thread asynchronously
DOn the native thread after a delay
Attempts:
2 left
💡 Hint
Worklets run on the UI thread for smooth animations.
📝 Syntax
advanced
2: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();
ANo error, runs correctly
BSyntaxError: Missing semicolon
CTypeError: progress.value is not a number
DReferenceError: progress is not defined inside worklet
Attempts:
2 left
💡 Hint
Worklets have isolated scope and cannot access variables outside unless passed or declared.
navigation
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?
AUse <code>withTiming</code> callback to call navigation inside the worklet
BCall navigation immediately after starting animation without callback
CUse <code>runOnJS</code> inside animation callback to call navigation function
DUse <code>setTimeout</code> with animation duration to call navigation
Attempts:
2 left
💡 Hint
Navigation functions run on JS thread, so use runOnJS to call them from worklet.
🧠 Conceptual
expert
2: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?
AWorklets allow animations to run on the UI thread, making them smoother and avoiding JS thread delays
BWorklets simplify writing animations by using plain JavaScript without any restrictions
CWorklets automatically optimize battery usage by reducing CPU frequency
DWorklets enable animations to run on the native thread with direct hardware access
Attempts:
2 left
💡 Hint
Think about what causes janky animations in React Native.