David Ewins
Error library

Reanimated crash on device: Tried to synchronously call a non-worklet function on the UI thread

React NativeConfirmed fix

Reanimated 4 / react-native-worklets

Error
[Worklets] Tried to synchronously call a non-worklet function `clamp01` on the UI thread.

Cause

A useAnimatedStyle / useDerivedValue body called a plain module-level helper. Inside a worklet you can only call other worklets, Reanimated built-ins and JS globals. It compiles fine and only crashes on device.

Fix

Inline the math (Math.max(0, Math.min(1, x))), use interpolateColor for colours, or compute the value outside the worklet and pass the primitive in. Only add 'worklet' to a helper if it is pure.

More React Native errors

Search all errors