Communitygithub.com

React Native Reanimated

React Native Reanimated ist eine Animationsbibliothek für React Native, die Animationen über Worklets und Shared Values auf dem UI-Thread ausführt, damit sie flüssig bleiben, während der JavaScript-Thread ausgelastet ist.

Was ist React Native Reanimated?

Diese Fähigkeit befähigt einen KI-Agenten, hochwertige, flüssige Animationen in React Native-Anwendungen mit der Reanimated-Bibliothek zu erstellen, insbesondere Version 4. Sie umfasst die Erstellung von Animationen mit Shared Values und Animated Styles, gestengesteuerten Interaktionen (wie Wischen zum Löschen), Layout-Animationen für Listen, scrollgesteuerten Effekten (z. B. Parallax-Header) sowie die neuen CSS-Transitions und geteilten Elementübergänge von Reanimated 4. Der Agent kann Codebeispiele für verschiedene Szenarien generieren, von einfachen Einblendkarten bis hin zu komplexeren Komponenten wie einem Tinder-ähnlichen Karten-Swipe-Interface oder einem anpassbaren Bottom Sheet. Die Anleitung behandelt die Einrichtung, die Unterschiede zwischen Reanimated 3 und 4, die Integration mit React Native Gesture Handler und wichtige Best Practices wie die Verwendung von `scheduleOnRN` für den Aufruf von JS-Thread-Funktionen aus Worklets. Die Fähigkeit ist für Entwickler gedacht, die reibungslose, performante Animationen in React Native benötigen, die auf dem nativen UI-Thread ausgeführt werden, um 60 fps oder mehr zu erreichen.

Funktioniert mit~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/TerminalSkills/skills/tree/HEAD/skills/react-native-reanimated

In Ihrer bevorzugten KI fragen

Öffnet einen neuen Chat, in dem dieser Agent-Skill bereits geladen ist.

Dokumentation

Was macht React Native Reanimated?

Überblick

Reanimated führt Animationen auf dem nativen UI-Thread aus, sodass sie mit 60fps (oder der Bildwiederholrate des Displays) laufen, selbst wenn der JavaScript-Thread ausgelastet ist. Es verwendet "Worklets": kleine JavaScript-Funktionen, die über JSI auf dem UI-Thread ausgeführt werden. Es ist der Standard für produktionsreife Animationen in React Native: gestengesteuerte Interaktionen, Layout-Übergänge, scrollbasierte Effekte und geteilte Elementübergänge.

Diese Fähigkeit zielt auf Reanimated 4 (4.7.0, September 2026). Version 4 funktioniert nur mit der Neuen Architektur, verschiebt Worklets in das separate Paket react-native-worklets und fügt CSS-ähnliche Übergänge und Animationen hinzu. Apps, die noch auf der alten Architektur laufen, bleiben bei 3.x, das nicht mehr aktiv gewartet wird.

Wann verwenden

  • Jede Animation in React Native, die über einfache Opazität/Transformation hinausgeht
  • Gestengesteuerte Interaktionen (Wischen zum Löschen, Ziehen zum Neuanordnen, Pinch-to-Zoom)
  • Scrollgesteuerte Animationen (Parallax-Header, klebrige Elemente)
  • Layout-Animationen (Elemente, die in Listen ein- oder austreten)
  • Geteilte Elementübergänge zwischen Bildschirmen (experimentell in 4.x)

Anleitung

Einrichtung

# Expo: installiert die vom SDK festgelegten Versionen (SDK 57: Reanimated 4.5, Worklets 0.10, Gesture Handler 2.32)
npx expo install react-native-reanimated react-native-worklets react-native-gesture-handler
npx expo prebuild        # nur für Development Builds: generiert ios/ und android/ neu

# React Native Community CLI
npm install react-native-reanimated react-native-worklets react-native-gesture-handler
cd ios && pod install && cd ..
npm start -- --reset-cache
  • Expo: babel-preset-expo fügt das Worklets-Babel-Plugin automatisch hinzu; nicht in babel.config.js aufführen.
  • Community CLI: füge 'react-native-worklets/plugin' als letzten Eintrag der plugins in babel.config.js hinzu. Der Reanimated-3-Name react-native-reanimated/plugin funktioniert in 4.x noch, ist aber die veraltete Schreibweise.
  • Jede Reanimated-Nebenversion akzeptiert spezifische react-native-worklets- und React-Native-Versionen (4.7 benötigt Worklets 0.13 und RN 0.86–0.88); vor einem manuellen Upgrade die Kompatibilitätstabelle prüfen.
  • Für Gesten die App-Wurzel in GestureHandlerRootView von react-native-gesture-handler mit style={{ flex: 1 }} einwickeln.

Shared Values und Animierte Styles

// components/FadeIn.tsx — Basis-Animation mit Shared Values
import Animated, { useSharedValue, useAnimatedStyle, withTiming, withSpring } from "react-native-reanimated";
import { type ReactNode, useEffect } from "react";

export function FadeInCard({ children }: { children: ReactNode }) {
  const opacity = useSharedValue(0);
  const translateY = useSharedValue(20);
  useEffect(() => {
    opacity.value = withTiming(1, { duration: 600 });
    translateY.value = withSpring(0);
  }, []);
  const animatedStyle = useAnimatedStyle(() => ({
    opacity: opacity.value,
    transform: [{ translateY: translateY.value }],
  }));

  return <Animated.View style={[{ backgroundColor: "white", padding: 16 }, animatedStyle]}>{children}</Animated.View>;
}

.value nur in Effekten, Ereignisbehandlern und Worklets lesen und schreiben, niemals während des Renderings. Mit dem React Compiler opacity.get() und opacity.set(1) anstelle von .value verwenden.

Gesten-Animationen

// components/SwipeToDelete.tsx — Wischgeste mit Animation
import Animated, { useSharedValue, useAnimatedStyle, withSpring } from "react-native-reanimated";
import { Gesture, GestureDetector } from "react-native-gesture-handler";
import { scheduleOnRN } from "react-native-worklets";
import type { ReactNode } from "react";

export function SwipeToDelete({ onDelete, children }: { onDelete: () => void; children: ReactNode }) {
  const translateX = useSharedValue(0);
  const pan = Gesture.Pan()
    .onUpdate((event) => {
      translateX.value = Math.min(0, event.translationX);   // nur nach links wischen erlauben
    })
    .onEnd((event) => {
      if (event.translationX < -150) {
        translateX.value = withSpring(-400);
        scheduleOnRN(onDelete);            // eine JS-Thread-Funktion vom UI-Thread aus aufrufen
      } else {
        translateX.value = withSpring(0);  // zurückschnappen
      }
    });
  const animatedStyle = useAnimatedStyle(() => ({ transform: [{ translateX: translateX.value }] }));
  return (
    <GestureDetector gesture={pan}>
      <Animated.View style={animatedStyle}>{children}</Animated.View>
    </GestureDetector>
  );
}

scheduleOnRN(fn, ...args) ersetzt runOnJS(fn)(...args), das in 4.x veraltet ist. Gesture.Pan() ist die Gesture-Handler-2-Builder-API, die Expo SDK 57 installiert; Gesture Handler 3 behält sie bei und fügt Hooks hinzu (usePanGesture({ onUpdate, onDeactivate }), wobei onStart/onEnd in onActivate/onDeactivate umbenannt sind).

Layout-Animationen

// components/AnimatedList.tsx — Elemente animieren automatisch ein/aus
import Animated, { FadeInDown, FadeOutLeft, LinearTransition } from "react-native-reanimated";
import { Pressable, Text } from "react-native";

type Item = { id: string; title: string };
export function AnimatedList({ items, onRemove }: { items: Item[]; onRemove: (id: string) => void }) {
  return (
    <Animated.FlatList
      data={items}
      keyExtractor={(item) => item.id}
      itemLayoutAnimation={LinearTransition}   // verbleibende Zeilen gleiten an Ort und Stelle; nur einzelne Spalte
      renderItem={({ item, index }) => (
        <Animated.View
          entering={FadeInDown.delay(index * 100).springify()}
          exiting={FadeOutLeft.duration(300)}
          style={{ backgroundColor: "white", padding: 16, marginVertical: 4, borderRadius: 8 }}
        >
          <Text>{item.title}</Text>
          <Pressable onPress={() => onRemove(item.id)}><Text style={{ color: "#dc2626" }}>Entfernen</Text></Pressable>
        </Animated.View>
      )}
    />
  );
}

Scrollgesteuerte Animationen

// components/ParallaxHeader.tsx — Parallax-Effekt beim Scrollen
import Animated, {
  useAnimatedScrollHandler, useSharedValue, useAnimatedStyle, interpolate, Extrapolation,
} from "react-native-reanimated";
import { Text } from "react-native";

export function ParallaxHeader() {
  const scrollY = useSharedValue(0);
  const scrollHandler = useAnimatedScrollHandler({
    onScroll: (event) => { scrollY.value = event.contentOffset.y; },
  });
  const headerStyle = useAnimatedStyle(() => ({
    height: interpolate(scrollY.value, [-100, 0, 200], [400, 300, 100], Extrapolation.CLAMP),
    opacity: interpolate(scrollY.value, [0, 200], [1, 0.3], Extrapolation.CLAMP),
  }));

  return (
    <>
      <Animated.View style={[{ backgroundColor: "#2563eb" }, headerStyle]}>
        <Text style={{ color: "white", fontSize: 28, fontWeight: "bold" }}>Wegelogbuch</Text>
      </Animated.View>
      <Animated.ScrollView onScroll={scrollHandler}>{/* Inhalt */}</Animated.ScrollView>
    </>
  );
}

Wenn nur der Offset benötigt wird, gibt useScrollOffset(animatedRef) (in 3.x useScrollViewOffset genannt) ihn als Shared Value ohne Handler zurück.

CSS-Übergänge und geteilte Elemente (Reanimated 4)

// eine Zustandsänderung animiert von selbst: kein Shared Value, kein Hook
<Animated.View
  style={{
    height: 80,
    width: expanded ? 240 : 120,
    backgroundColor: expanded ? "#16a34a" : "#2563eb",
    transitionProperty: ["width", "backgroundColor"],
    transitionDuration: 300,
  }}
/>

// dasselbe Tag auf zwei Bildschirmen eines nativen Stacks animiert das Element zwischen ihnen
<Animated.Image sharedTransitionTag="trail-42-photo" source={{ uri: photoUrl }} style={{ width: 120, height: 120 }} />

Geteilte Elementübergänge sind in 4.x experimentell und standardmäßig deaktiviert. Aktiviere sie mit "reanimated": { "staticFeatureFlags": { "ENABLE_SHARED_ELEMENT_TRANSITIONS": true } } in der package.json der App (4.2+), dann die native App neu erstellen; statische Flags können in Expo Go nicht geändert werden.

Beispiele

Beispiel 1: Karten-Swipe-Interface erstellen

Benutzeraufforderung: "Erstelle ein Tinder-ähnliches Karten-Swipe-Interface mit flüssigen Animationen."

// components/SwipeCard.tsx
import Animated, { interpolate, useAnimatedStyle, useSharedValue, withSpring, withTiming } from "react-native-reanimated";
import { Gesture, GestureDetector } from "react-native-gesture-handler";
import { scheduleOnRN } from "react-native-worklets";
import { useWindowDimensions } from "react-native";
import type { ReactNode } from "react";

type Props = { children: ReactNode; onSwipe: (direction: "left" | "right") => void };
export function SwipeCard({ children, onSwipe }: Props) {
  const { width } = useWindowDimensions();
  const x = useSharedValue(0);
  const y = useSharedValue(0);
  const pan = Gesture.Pan()
    .onUpdate((e) => { x.value = e.translationX; y.value = e.translationY; })
    .onEnd((e) => {
      if (Math.abs(e.translationX) > width * 0.3) {
        const direction = e.translationX > 0 ? "right" : "left";
        x.value = withTiming(Math.sign(e.translationX) * width * 1.5, { duration: 200 }, (finished) => {
          if (finished) scheduleOnRN(onSwipe, direction);   // Karte im React-Zustand entfernen
        });
      } else {
        x.value = withSpring(0);
        y.value = withSpring(0);
      }
    });

  const style = useAnimatedStyle(() => ({
    transform: [{ translateX: x.value }, { translateY: y.value }, { rotate: `${interpolate(x.value, [-width, 0, width], [-15, 0, 15])}deg` }],
  }));

  return (
    <GestureDetector gesture={pan}>
      <Animated.View style={style}>{children}</Animated.View>
    </GestureDetector>
  );
}

Ergebnis: Die Karte folgt dem Finger und neigt sich um bis zu 15°. Wird sie über 30% der Bildschirmbreite losgelassen, fliegt sie weg und onSwipe("left" | "right") wird auf dem JS-Thread ausgeführt; andernfalls springt sie in die Mitte zurück.

Beispiel 2: Animiertes Bottom Sheet

Benutzeraufforderung: "Erstelle ein Bottom Sheet, das hochgezogen werden kann und an Positionen einrastet."

// components/BottomSheet.tsx
import Animated, { useAnimatedStyle, useSharedValue, withSpring } from "react-native-reanimated";
import { Gesture, GestureDetector } from "react-native-gesture-handler";
import { useWindowDimensions } from "react-native";
import type { ReactNode } from "react";

export function BottomSheet({ children }: { children: ReactNode }) {
  const { height } = useWindowDimensions();
  const snapPoints = [height * 0.1, height * 0.5, height * 0.85]; // oberer Rand: offen, halb, Vorschau
  const top = useSharedValue(snapPoints[2]);
  const start = useSharedValue(0);
  const pan = Gesture.Pan()
    .onBegin(() => { start.value = top.value; })
    .onUpdate((e) => { top.value = Math.max(snapPoints[0], start.value + e.translationY); })
    .onEnd((e) => {
      const projected = top.value + e.velocityY * 0.2; // wo der Wurf landen würde
      const target = snapPoints.reduce((a, b) => (Math.abs(b - projected) < Math.abs(a - projected) ? b : a));
      top.value = withSpring(target, { velocity: e.velocityY });
    });

  const style = useAnimatedStyle(() => ({ transform: [{ translateY: top.value }] }));
  const sheet = { position: "absolute", left: 0, right: 0, top: 0, height, backgroundColor: "white" } as const;

  return (
    <GestureDetector gesture={pan}>
      <Animated.View style={[sheet, style]}>{children}</Animated.View>
    </GestureDetector>
  );
}

Ergebnis: Das Sheet beginnt in der Vorschauposition, folgt dem Ziehen und springt beim Loslassen zum nächstgelegenen der drei Einrastpunkte, unter Berücksichtigung der Wurfgeschwindigkeit.

Richtlinien

  • Shared Values für Animationszustand — useSharedValue lebt auf dem UI-Thread; eine Änderung führt kein erneutes Rendern der Komponente durch
  • useAnimatedStyle für dynamische Styles — wird auf dem UI-Thread neu berechnet
  • withSpring für natürliche Bewegung — withTiming für präzise Dauer. Version 4 hat die Spring-Standardwerte geändert (Dämpfung 120, Steifigkeit 900) und behandelt duration als wahrnehmbar; Reanimated3DefaultSpringConfig stellt das alte Gefühl wieder her
  • scheduleOnRN zum Aufruf von JS aus Worklets — eine Funktion übergeben, die im Komponenten- oder Modulbereich definiert wurde, nicht eine, die innerhalb des Worklets erstellt wurde
  • Gesture-Handler-Integration — Gesture.Pan(), Gesture.Pinch() usw.; inline übergebene Callbacks werden automatisch workletisiert, ein in einer Variable gespeicherter Callback benötigt eine 'worklet';-Direktive
  • Layout-Animationen sind deklarativ — entering-, exiting-Props auf Animated-Komponenten
  • interpolate zur Wertezuordnung — Scrollposition auf Opazität, Skalierung usw. abbilden; Extrapolation.CLAMP übergeben, um an den Bereichsgrenzen anzuhalten
  • Worklets-Babel-Plugin muss zuletzt kommen — und nach Änderung der Babel-Konfiguration den Metro-Cache leeren
  • Keine großen Objekte in Worklets erfassen — erfasste Werte werden in die UI-Laufzeit kopiert; Shared Values, Primitive und kleine, einfache Objekte übergeben
  • Upgrade von 3.x — zuerst die Neue Architektur aktivieren, react-native-worklets installieren, das Babel-Plugin umbenennen und useAnimatedGestureHandler, useWorkletCallback und combineTransition ersetzen, die entfernt wurden
  • Wann nicht verwenden — ein einmaliges Ein- oder Ausblenden, das nie blockiert, kann mit der eingebauten Animated-API von React Native bleiben (CSS-Übergänge auf natives Systemen kommen von Reanimated selbst); Reanimated 4 kann nicht in einer App auf der alten Architektur installiert werden

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

TerminalSkills/skills

>- Run GitHub Actions locally with act. Use when a user asks to test GitHub Actions workflows locally, debug CI pipelines without pushing, or run workflows offline.

TerminalSkills/skills

>- You are an expert in AG2 (formerly AutoGen), the open-source multi-agent conversation framework. You help developers build systems where multiple AI agents collaborate through structured conversations — with tool use, human-in-the-loop, code execution, group chat orchestration, and nested conversations — for complex tasks like software development, research, and data analysis.

TerminalSkills/skills

>- Generate short-form videos with AI — script writing, text-to-speech narration, stock footage selection, subtitle generation, and video assembly. Use when: creating TikTok/YouTube Shorts/Reels content, automating video production, building content pipelines.

TerminalSkills/skills

>- Animate 3D objects and characters in Blender with Python. Use when the user wants to keyframe properties, create armatures and rigs, set up IK/FK chains, animate shape keys for facial animation, edit F-Curves, use the NLA editor to blend actions, add drivers for expression-based animation, or script any animation workflow in Blender.

TerminalSkills/skills

>- Automate motion capture and tracking workflows in Blender with Python. Use when the user wants to import BVH or FBX mocap data, retarget motion to armatures, track camera or object motion from video, solve camera motion, clean up motion capture data, or script any tracking pipeline in Blender.

TerminalSkills/skills

>- You are an expert in Bolt.new by StackBlitz, the AI-powered full-stack development environment that runs entirely in the browser. You help developers go from idea to deployed app in minutes using natural language prompts — Bolt generates complete applications with frontend, backend, database, and deployment, all running in a WebContainer without local setup.

TerminalSkills/skills

>- Assists with using Bun as an all-in-one JavaScript/TypeScript runtime, package manager, bundler, and test runner. Use when building HTTP servers, managing packages, running tests, or migrating from Node.js. Trigger words: bun, bun serve, bun install, bun test, bun build, javascript runtime, bun runtime.

TerminalSkills/skills

>- Self-host customer support with Chatwoot. Use when a user asks to set up open-source customer support, add live chat without SaaS costs, build a multi-channel inbox, or deploy a free Intercom alternative.

TerminalSkills/skills

>- You are an expert in Chi, the lightweight, idiomatic Go HTTP router built on `net/http`. You help developers build composable HTTP services using Chi's middleware stack, route groups, URL parameters, sub-routers, and context-based request scoping — providing Express-like ergonomics while staying 100% compatible with Go's standard library.

TerminalSkills/skills

When the user wants to edit, review, or improve existing marketing copy. Also use when the user mentions 'edit this copy,' 'review my copy,' 'copy feedback,' 'proofread,' 'polish this,' 'make this better,' or 'copy sweep.' This skill provides a systematic approach to editing marketing copy through multiple focused passes.

TerminalSkills/skills

>- Add live chat and customer support with Crisp. Use when a user asks to add a chat widget, implement live customer support, set up a help desk, create a knowledge base, or add a chatbot to a website.

TerminalSkills/skills

>- Assists with building custom interactive data visualizations using D3.js. Use when creating charts, graphs, maps, force layouts, or hierarchical diagrams that require fine-grained control beyond what charting libraries provide. Trigger words: d3, data visualization, chart, svg, scales, force graph, treemap, choropleth.

TerminalSkills/skills

dbt (data build tool) transforms data in your warehouse using SQL SELECT statements. Learn project setup, models, tests, documentation, incremental materializations, and integration with data warehouses like PostgreSQL, BigQuery, and Snowflake.

TerminalSkills/skills

>- You are an expert in dlt, the open-source Python library for building data pipelines. You help developers load data from any API, file, or database into warehouses and lakes using simple Python decorators — with automatic schema inference, incremental loading, and built-in data contracts. dlt is the "requests library for data pipelines.

TerminalSkills/skills

Data Version Control for ML projects. Track large datasets and models alongside Git, build reproducible ML pipelines, and run experiments with metric comparison. Works with any storage backend including S3, GCS, Azure, and local filesystems.

TerminalSkills/skills

>- You are an expert in E2B, the cloud platform for running AI-generated code in secure sandboxes. You help developers give AI agents the ability to execute code, install packages, read/write files, and run long processes in isolated cloud environments — each sandbox is a lightweight VM that boots in ~150ms with full Linux, filesystem, and networking.

TerminalSkills/skills

>- Transcode, convert, edit, and process audio and video with FFmpeg. Use when a user asks to convert video formats (webm to mp4, mkv to mp4), extract audio from video, compress video files, trim or cut clips, concatenate videos, add subtitles, create thumbnails, apply filters, change resolution or bitrate, re-encode media, create GIFs from video, add watermarks, normalize audio, stream media, or build automated media processing pipelines.

TerminalSkills/skills

>- Create advanced animations with GSAP. Use when building complex timelines, scroll-driven animations, SVG morphing, text animations, or high-performance web animations beyond CSS capabilities.

TerminalSkills/skills

>- Generate deterministic MP4 videos from HTML, CSS, media, and seekable animations using HeyGen's HyperFrames framework. Use when someone asks to "render HTML to video", "make a video with HyperFrames", "create a programmatic video", "turn an animation into MP4", "build a launch/product video from HTML", "render GSAP/Lottie/Three.js to video", or set up an agent-driven video pipeline. Covers init/preview/render/add/lint/inspect commands, data-* timing attributes, animation adapters, and the component catalog.

TerminalSkills/skills

When the user wants to perform load testing, stress testing, or performance testing of APIs and websites using k6. Also use when the user mentions "k6," "load test," "performance test," "stress test," "spike test," "soak test," "thresholds," "virtual users," or "VUs." For browser-based testing, see selenium.

Verwandte Skills