Communitygithub.com

React Native Reanimated

Reanimatedは、アニメーションをネイティブUIスレッドで実行します。JSブリッジのボトルネックやフレーム落ちがなく、JavaScriptスレッドがビジーな状態でもアニメーションは60fpsを維持します。'ワークレット'と呼ばれる、JSIを介してUIスレッド上で実行される小さなJavaScript関数を使用します。React Nativeにおけるプロダクション品質のアニメーション(ジェスチャ駆動のインタラクション、レイアウト遷移、スクロールベースのエフェクト、共有要素トランジション)の標準です。

React Native Reanimated とは?

このスキルは、React Nativeアプリケーションにおける高パフォーマンスなアニメーションを実現するためのライブラリ「Reanimated」の使用方法を提供します。ReanimatedはアニメーションをJavaScriptスレッドではなくネイティブUIスレッドで実行することで、JSブリッジのボトルネックを解消し、60fpsの滑らかなアニメーションを可能にします。スキルには、基本的な共有値とアニメーションスタイルの設定、スワイプやパンなどのジェスチャアニメーション、リストのアイテムが出入りする際のレイアウトアニメーション、スクロールに連動するパララックス効果など、実践的なコード例が含まれています。各コード例は、Expo環境でのセットアップ手順から、具体的なコンポーネント実装までを網羅しており、開発者がすぐにプロジェクトに応用できるよう設計されています。このスキルは、特にClaude CodeやCursor、CodexなどのAIエージェントがReact Native開発を支援する際に有用です。

対応~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/ComeOnOliver/skillshub/tree/HEAD/skills/TerminalSkills/skills/react-native-reanimated

お気に入りのAIに質問する

このエージェントスキルを事前に読み込んだ状態で新しいチャットを開きます。

ドキュメント

React Native Reanimated は何をしますか?

概要

Reanimatedは、アニメーションをネイティブUIスレッドで実行します。JSブリッジのボトルネックやフレーム落ちがなく、JavaScriptスレッドがビジーな状態でもアニメーションは60fpsを維持します。'ワークレット'と呼ばれる、JSIを介してUIスレッド上で実行される小さなJavaScript関数を使用します。React Nativeにおけるプロダクション品質のアニメーション(ジェスチャ駆動のインタラクション、レイアウト遷移、スクロールベースのエフェクト、共有要素トランジション)の標準です。

使用するタイミング

  • React Nativeにおける、単純なopacity/transformを超えるあらゆるアニメーション
  • ジェスチャ駆動のインタラクション(スワイプして削除、ドラッグして並べ替え、ピンチでズーム)
  • スクロール駆動のアニメーション(パララックスヘッダー、スティッキー要素)
  • レイアウトアニメーション(リストへのアイテムの出入り)
  • 画面間の共有要素トランジション

手順

セットアップ

npx expo install react-native-reanimated react-native-gesture-handler
// babel.config.js — Reanimatedプラグインを追加(必ず最後に記述)
module.exports = function (api) {
  api.cache(true);
  return {
    presets: ["babel-preset-expo"],
    plugins: ["react-native-reanimated/plugin"],  // 必ず最後に記述!
  };
};

共有値とアニメーションスタイル

// components/FadeIn.tsx — 共有値を使用した基本的なアニメーション
import Animated, {
  useSharedValue,
  useAnimatedStyle,
  withTiming,
  withSpring,
} from "react-native-reanimated";
import { useEffect } from "react";

export function FadeInCard({ children }) {
  const opacity = useSharedValue(0);
  const translateY = useSharedValue(20);

  useEffect(() => {
    opacity.value = withTiming(1, { duration: 600 });
    translateY.value = withSpring(0, { damping: 15 });
  }, []);

  const animatedStyle = useAnimatedStyle(() => ({
    opacity: opacity.value,
    transform: [{ translateY: translateY.value }],
  }));

  return (
    <Animated.View style={animatedStyle} className="bg-white rounded-xl p-4 shadow-lg">
      {children}
    </Animated.View>
  );
}

ジェスチャアニメーション

// components/SwipeToDelete.tsx — スワイプジェスチャとアニメーション
import Animated, {
  useSharedValue,
  useAnimatedStyle,
  withSpring,
  runOnJS,
} from "react-native-reanimated";
import { Gesture, GestureDetector } from "react-native-gesture-handler";

export function SwipeToDelete({ onDelete, children }) {
  const translateX = useSharedValue(0);

  const pan = Gesture.Pan()
    .onUpdate((event) => {
      // 左スワイプのみ許可
      translateX.value = Math.min(0, event.translationX);
    })
    .onEnd((event) => {
      if (event.translationX < -150) {
        // 十分にスワイプされた — 削除
        translateX.value = withSpring(-400);
        runOnJS(onDelete)();
      } else {
        // 元の位置にスナップバック
        translateX.value = withSpring(0);
      }
    });

  const animatedStyle = useAnimatedStyle(() => ({
    transform: [{ translateX: translateX.value }],
  }));

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

レイアウトアニメーション

// components/AnimatedList.tsx — アイテムが自動的にアニメーションしながら出入り
import Animated, { FadeInDown, FadeOutLeft, LinearTransition } from "react-native-reanimated";

export function AnimatedList({ items, onRemove }) {
  return (
    <Animated.FlatList
      data={items}
      itemLayoutAnimation={LinearTransition}
      renderItem={({ item, index }) => (
        <Animated.View
          entering={FadeInDown.delay(index * 100).springify()}
          exiting={FadeOutLeft.duration(300)}
          className="bg-white p-4 mx-4 my-1 rounded-lg"
        >
          <Text>{item.title}</Text>
          <Pressable onPress={() => onRemove(item.id)}>
            <Text className="text-red-500">削除</Text>
          </Pressable>
        </Animated.View>
      )}
    />
  );
}

スクロール駆動アニメーション

// components/ParallaxHeader.tsx — スクロールに応じたパララックス効果
import Animated, {
  useAnimatedScrollHandler,
  useSharedValue,
  useAnimatedStyle,
  interpolate,
} from "react-native-reanimated";

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]),
    opacity: interpolate(scrollY.value, [0, 200], [1, 0.3]),
    transform: [
      { translateY: interpolate(scrollY.value, [0, 200], [0, -50]) },
    ],
  }));

  return (
    <>
      <Animated.View style={headerStyle} className="bg-blue-600">
        <Text className="text-white text-3xl font-bold">My App</Text>
      </Animated.View>
      <Animated.ScrollView onScroll={scrollHandler} scrollEventThrottle={16}>
        {/* コンテンツ */}
      </Animated.ScrollView>
    </>
  );
}

使用例

例1: カードスワイプインターフェースの構築

ユーザープロンプト: "スムーズなアニメーションでTinder風のカードスワイプインターフェースを構築してください。"

エージェントは、パンジェスチャ、スワイプ方向に基づく回転、スナップバック用のスプリングアニメーション、カード削除時のレイアウトトランジションを備えたカードスタックを作成します。

例2: アニメーションボトムシート

ユーザープロンプト: "ドラッグして引き上げ、特定の位置にスナップするボトムシートを作成してください。"

エージェントは、スナップポイント付きのパンジェスチャ、高さの共有値、スムーズなスナップのためのスプリングアニメーションを使用します。

ガイドライン

  • アニメーション状態には共有値を使用 — useSharedValue はUIスレッドで実行
  • 動的スタイルには useAnimatedStyle — UIスレッドで再計算
  • 自然な動きには withSpring — 正確な継続時間が必要な場合は withTiming
  • ワークレットからJSを呼び出すには runOnJS — 必要な場合にJSスレッドにブリッジ
  • Gesture Handlerとの統合 — Gesture.Pan(), Gesture.Pinch() など
  • レイアウトアニメーションは宣言的 — Animatedコンポーネントの entering, exiting プロパティ
  • 値のマッピングには interpolate — スクロール位置をopacity、scaleなどにマッピング
  • Babelプラグインは最後に記述 — react-native-reanimated/plugin をplugins配列の末尾に
  • ワークレット内でJSオブジェクトにアクセスしない — 共有値とプリミティブのみ
  • scrollEventThrottle={16} — スムーズなアニメーションのために60fpsのスクロールイベント

Individual skills in this repo

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

ComeOnOliver/skillshub

Create stunning, animation-rich HTML presentations from scratch or by converting PowerPoint files. Use when the user wants to build a presentation, convert a PPT/PPTX to web, or create slides for a talk/pitch. Helps non-designers discover their aesthetic through visual exploration rather than abstract choices.

ComeOnOliver/skillshub

Next.js 16+ 和 Turbopack — 增量打包、文件系统缓存、开发速度,以及何时使用 Turbopack 与 webpack。

ComeOnOliver/skillshub

SwiftUI architecture patterns, state management with @Observable, view composition, navigation, performance optimization, and modern iOS/macOS UI best practices.

ComeOnOliver/skillshub

See, Understand, Act on video and audio. See- ingest from local files, URLs, RTSP/live feeds, or live record desktop; return realtime context and playable stream links. Understand- extract frames, build visual/semantic/temporal indexes, and search moments with timestamps and auto-clips. Act- transcode and normalize (codec, fps, resolution, aspect ratio), perform timeline edits (subtitles, text/image overlays, branding, audio overlays, dubbing, translation), generate media assets (image, audio, video), and create real time alerts for events from live streams or desktop capture.

ComeOnOliver/skillshub

AI-assisted video editing workflows for cutting, structuring, and augmenting real footage. Covers the full pipeline from raw capture through FFmpeg, Remotion, ElevenLabs, fal.ai, and final polish in Descript or CapCut. Use when the user wants to edit video, cut footage, create vlogs, or build video content.

ComeOnOliver/skillshub

Next.js 15 애플리케이션을 위한 프론트엔드 개발 가이드라인. React 19, TypeScript, Shadcn/ui, Tailwind CSS를 사용한 모던 패턴. Server Components, Client Components, App Router, 파일 구조, Shadcn/ui 컴포넌트, 성능 최적화, TypeScript 모범 사례 포함. 컴포넌트, 페이지, 기능 생성, 데이터 페칭, 스타일링, 라우팅, 프론트엔드 코드 작업 시 사용.

ComeOnOliver/skillshub

Provides Tamagui patterns for config v4, compiler optimization, styled context, and cross-platform styling. Must use when working with Tamagui projects (tamagui.config.ts, @tamagui imports).

ComeOnOliver/skillshub

Create distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.

ComeOnOliver/skillshub

Create high-converting, visually distinctive landing pages. Use when building marketing pages, product launches, SaaS homepages, or any single-page conversion-focused website. Guides section-by-section composition with anti-AI-slop principles.

ComeOnOliver/skillshub

Auto-loaded context for Portfolio Buddy 2 development. Use for ANY task involving: React 19 development, TypeScript, portfolio analysis features, metrics calculations, trading strategy comparison, or working with the Portfolio Buddy 2 codebase. Contains tech stack, known issues, and architectural constraints.

ComeOnOliver/skillshub

Next.js development tooling via MCP. Inspect routes, components, build info, and debug Next.js apps. Use when working on Next.js applications, debugging routing, or inspecting app structure. NOT for general React or non-Next.js projects.

ComeOnOliver/skillshub

Implement UI using Shadcn MCP (atoms/theme) and 21st.dev MCP (complex sections). Use when adding buttons, layouts, or generating landing pages.

ComeOnOliver/skillshub

A conceptual skill for building an API client in Next.js that handles JWT tokens

ComeOnOliver/skillshub

Best practices and patterns for Next.js App Router, Server Actions, and Routing in this project.

ComeOnOliver/skillshub

The Design System, Theme, and UX rules for the Physical AI Hub.

ComeOnOliver/skillshub

Comprehensive frontend development skill for building modern, performant web applications using ReactJS, NextJS, TypeScript, Tailwind CSS. Includes component scaffolding, performance optimization, bundle analysis, and UI best practices. Use when developing frontend features, optimizing performance, implementing UI/UX designs, managing state, or reviewing frontend code.

ComeOnOliver/skillshub

This document captures learnings from fixing keyboard navigation issues when floating components (Select, DropdownMenu, Popover) have CSS open/close animations.

ComeOnOliver/skillshub

Build Next.js 16 applications with correct patterns and distinctive design. Use when creating pages, layouts, dynamic routes, upgrading from Next.js 15, or implementing proxy.ts. Covers breaking changes (async params/searchParams, Turbopack, cacheComponents) and frontend aesthetics. NOT when building non-React or backend-only applications.

ComeOnOliver/skillshub

Comprehensive Framer Motion animation library for React. Covers motion components, variants, gestures, page transitions, and scroll animations. Use when adding animations to React/Next.js applications.

ComeOnOliver/skillshub

Build interfaces that resonate, not just render. This skill enforces bold, intentional

関連スキル