---
name: react-native-motion
description: Use when building animations in React Native or Expo with Reanimated, Gesture Handler and Skia, keeping everything on the UI thread at 60-120fps.
---

# React Native motion

Run animations on the UI thread with Reanimated so they stay smooth even when JavaScript is busy.

## Setup

- `react-native-reanimated` (v3+), `react-native-gesture-handler`, optional `@shopify/react-native-skia` for drawing.
- Keep animated values in `useSharedValue` and styles in `useAnimatedStyle`.

## Basics

```tsx
const scale = useSharedValue(1);
const style = useAnimatedStyle(() => ({ transform: [{ scale: scale.value }] }));
// press
scale.value = withSpring(0.96, { damping: 18, stiffness: 400 });
```

- `withTiming(value, { duration: 220, easing: Easing.bezier(0.16, 1, 0.3, 1) })` for fades and slides.
- `withSpring` for anything touched or interrupted.
- `withDecay({ velocity })` after flings.

## Gestures

```tsx
const pan = Gesture.Pan()
  .onChange((e) => { x.value += e.changeX; })
  .onEnd((e) => { x.value = withSpring(snap(x.value, e.velocityX)); });
```

## Layout animations

Use `entering={FadeInDown.springify()}`, `exiting={FadeOut}` and `layout={LinearTransition}` for lists.

## Shared element style transitions

Measure the source with `measure()` and animate an overlay from that frame to the target frame, then swap.

## Skia

Use Skia for blurs, gradients, particles and gooey effects (`Blur` plus `ColorMatrix` alpha threshold).

## Rules

- Never read shared values in render; never call JavaScript functions in worklets without `runOnJS`.
- Use `useReducedMotion()` and provide fades.
- Add haptics with `expo-haptics` at snaps and confirmations.
