Skip to content
useffect.sh
Book 30 min with a senior
UI

Reanimated

Software Mansion’s animation library that runs animations on the UI thread through worklets, without waiting on the JavaScript thread.

Definition

Reanimated (react-native-reanimated) is Software Mansion’s animation library for React Native. Its principle: animated values (shared values) and the functions updating them run on the UI thread, in a separate JavaScript runtime, as worklets. An animation or a gesture therefore keeps running at 60 or 120 frames per second even while the main JavaScript thread is busy with a React render or a network response. It replaces React Native’s Animated API for anything beyond a fade, and underpins React Navigation’s drawer and many sheet or carousel components. Version 4, restricted to the New Architecture, moves worklets into the react-native-worklets package and adds animations and transitions declared in CSS syntax. Since React Native 0.85.1, a shared animation backend for Animated and Reanimated is available as an experimental opt-in. It becomes necessary as soon as an animation has to follow a finger or hold up during a heavy render.

In a real app

In a project, the install is checked at three points: react-native-reanimated and react-native-worklets in the dependencies at compatible versions (the compatibility table is in the docs), the react-native-worklets/plugin Babel plugin last in babel.config.js, and a native rebuild after installing. The “Native part of Reanimated doesn’t seem to be initialized” error almost always comes from a Metro cache or a skipped native build.

The API to know: useSharedValue, useAnimatedStyle, withTiming, withSpring, withDecay, the withDelay, withRepeat, withSequence modifiers, and useAnimatedScrollHandler for anything driven by scroll. The most common pitfall is reading a shared value’s .value during React render: you get the JS-thread value, not the one of the animation in flight. The second is doing heavy work inside a worklet, which then blocks the UI thread instead of the JS thread.

Reanimated 4 requires the New Architecture; a project still on the old one has to stay on 3.x. CSS animations (animationName, transitionProperty on an Animated.View) cover the simple cases with less code and are a good entry point for a team coming from the web. To measure, the Performance panel in React Native DevTools shows whether an animation is falling back onto the JS thread.

Sources

All 35 glossary terms

One of these is blocking your app?

30 minutes with a senior to look at the problem in your code. Free.