Skip to main content
InterviewHubPRO
Section Overview
Q17

Question 17 of 50

Part 2: Core Architecture & Implementation (Mid-Level)

34%
React Native & Expo (50 Qs)•Part 2: Core Architecture & Implementation (Mid-Level)

How does React Native Reanimated 3 work using Worklets?

senior LevelCode ExampleSystem Design

In Simple Words: Traditional React animations run on the JS thread; if the JS thread is busy fetching data or rendering, animations drop frames:

  • Reanimated 3 Worklets: Small JavaScript functions annotated with 'worklet' that are compiled to run directly on the UI / Native Thread inside a separate Hermes runtime!
  • UI animations, gestures, and layout springs run at buttery smooth 60fps / 120fps even if the main JavaScript thread is completely blocked!
typescript
import Animated, { useSharedValue, useAnimatedStyle, withSpring } from "react-native-reanimated";

function BouncingBox() {
  const offset = useSharedValue(0);

  const animatedStyles = useAnimatedStyle(() => {
    'worklet';
    return { transform: [{ translateY: withSpring(offset.value * 200) }] };
  });

  return <Animated.View style={[styles.box, animatedStyles]} />;
}