Animations and gestures · senior
Reanimated: shared values and worklets
Reanimated runs small JS functions called worklets on a second JS runtime on the UI thread and connects them to React through shared values, so gesture- and scroll-driven animations update every frame without waiting for the JS thread.
Explain it out loud
Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.
Practise by voiceThe notes
What you must know
- Reanimated 4.x (4.7 in Nov 2026) is New Architecture only; old-architecture apps stay on 3.x. Worklets live in react-native-worklets; the Babel plugin is "react-native-worklets/plugin".
- A worklet is a function copied to the UI runtime (the "worklet" directive, or automatic inside useAnimatedStyle, useAnimatedScrollHandler and gesture callbacks). Variables it captures are copied when it is created.
- useSharedValue holds a value both runtimes can use. Use .value or get()/set() (recommended with React Compiler). Writing never re-renders React. Do not read or write it during render.
- useAnimatedStyle computes a style on the UI thread from shared values; useDerivedValue derives one shared value from others; withTiming, withSpring and withDecay animate them; interpolate maps ranges.
- To call JS (for example setState) from a worklet: scheduleOnRN(fn, ...args) (it replaced runOnJS(fn)(args), which is deprecated). From JS to the UI runtime: scheduleOnUI. Call back rarely (on end, not every frame).
- withSpring in v4: duration is perceptual (the spring really takes about 1.5× longer), the two rest thresholds became one energyThreshold, and defaults changed.
- useScrollViewOffset was renamed useScrollOffset; useAnimatedGestureHandler was removed (use Gesture Handler).
The red pen
Common traps: mistake → fix
Mistake: "I can call setState inside a worklet"
Fix: React state lives in the JS runtime; use scheduleOnRN.
Mistake: "runOnJS(fn)(x) is the current API"
Fix: deprecated in Reanimated 4; use scheduleOnRN(fn, x).
Mistake: "Shared values re-render like state"
Fix: writes never re-render.
Mistake: "Reanimated 4 works on the old architecture"
Fix: it needs the New Architecture.
Easy to hard
Questions interviewers ask, easy to hard
- What is a worklet and where does it run?
- This gesture callback calls setCount on every update. What happens? Fix it.
- What gets captured when a worklet is created?
- Why is reading sharedValue.value during render a smell?
- Build a header that collapses as the list scrolls.
Practise
Practise with these questions
Explain it out loud
Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.
Practise by voiceYour first interview is free
Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.