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
- Screen crashes the whole app: Rendered more hooks than during the previous renderRendered more hooks than during the previous render
- Feed shows an error state for every address: ReferenceError before initializationReferenceError: Cannot access 'scoreById' before initialization
- Screen crash: Maximum update depth exceededError: Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate.
- Rows wrapped in <Link asChild> collapse to a tiny height
- Pressable buttons render invisible: style function fill never applied