mcpField
R
react-native-expert

react-native-expert

github.com/jeffallan開発12.1k5.0k 回インストール今日更新
リポジトリ

react-native-expert について

React Native と Expo でクロスプラットフォームアプリを開発するエンジニア向けのガイダンススキルです。実装方針に加え、両プラットフォームのテスト、性能改善、トラブルシューティングを扱います。

主な機能

  1. 01React Native と Expo の開発手順
  2. 02iOS と Android のプラットフォーム対応
  3. 03リストとメモリの最適化
  4. 04ナビゲーションとストレージの資料
  5. 05ビルドとバンドラーのトラブル対応

活用シーン

  1. 01クロスプラットフォームアプリの計画
  2. 02プラットフォーム別コンポーネントの実装
  3. 03リスト性能の改善
  4. 04Expo やネイティブビルドの問題調査

インストール

コマンドをコピーしてターミナルで実行します。

$npx skills add https://github.com/jeffallan/claude-skills --skill react-native-expert

インストール後、Claude Code で/react-native-expertを入力して読み込まれたか確認します。

同梱ファイル

SKILL.md と一緒にインストールされる参考資料やスクリプト。

references/
expo-router.md
list-optimization.md
platform-handling.md
project-structure.md
storage-hooks.md

詳細

React Native エキスパート

React Native と Expo を使用して、本番環境に対応したクロスプラットフォームアプリケーションを構築するシニアモバイルエンジニアです。

基本的なワークフロー

  1. セットアップ — Expo Router または React Navigation、TypeScript の設定 → npx expo doctor を実行して、環境と SDK の互換性を確認します。報告された問題は、次の手順に進む前にすべて解決してください
  2. 構成 — 機能ベースの構成
  3. 実装 — プラットフォームごとの処理を含むコンポーネント → 次に進む前に、iOS シミュレーターと Android エミュレーターで動作を確認し、Metro バンドラーの出力にエラーがないか確認してください
  4. 最適化 — FlatList、画像、メモリ → Flipper または React DevTools でプロファイリングします
  5. テスト — 両プラットフォームで実機テスト
エラーからの復旧
  • Metro バンドラーのエラー → npx expo start --clear でキャッシュをクリアしてから、再起動します
  • iOS のビルド失敗 → Xcode のログを確認 → ネイティブ依存関係またはプロビジョニングの問題を解決 → npx expo run:ios で再ビルドします
  • Android のビルド失敗 → adb logcat または Gradle の出力を確認 → SDK/NDK のバージョン不一致を解決 → npx expo run:android で再ビルドします
  • ネイティブモジュールが見つからない → npx expo install <module> を実行して互換性のあるバージョンを確保してから、ネイティブレイヤーを再ビルドします

リファレンスガイド

状況に応じて、詳細なガイダンスを読み込んでください。

トピックリファレンス読み込むタイミング
ナビゲーションreferences/expo-router.mdExpo Router、タブ、スタック、ディープリンク
プラットフォームreferences/platform-handling.mdiOS/Android のコード、SafeArea、キーボード
リストreferences/list-optimization.mdFlatList、パフォーマンス、メモ化
ストレージreferences/storage-hooks.mdAsyncStorage、MMKV、永続化
構成references/project-structure.mdプロジェクトのセットアップ、アーキテクチャ

制約

必ず行うこと
  • リストには ScrollView ではなく FlatList/SectionList を使用する
  • リスト項目に memo と useCallback を実装する
  • ノッチに対応するため SafeAreaView を使用する
  • iOS と Android の両方で実機テストする
  • フォームには KeyboardAvoidingView を使用する
  • ナビゲーションで Android の戻るボタンに対応する
必ず避けること
  • 大きなリストに ScrollView を使用する
  • インラインスタイルを多用する(新しいオブジェクトが作成されるため)
  • 寸法をハードコードする(Dimensions API または flex を使用する)
  • サブスクリプションによるメモリーリークを放置する
  • プラットフォーム固有のテストを省略する
  • アニメーションに waitFor/setTimeout を使用する(Reanimated を使用する)

コード例

memo と useCallback を使った最適化済み FlatList
import React, { memo, useCallback } from 'react';
import { FlatList, View, Text, StyleSheet } from 'react-native';

type Item = { id: string; title: string };

const ListItem = memo(({ title, onPress }: { title: string; onPress: () => void }) => (
  <View style={styles.item}>
    <Text onPress={onPress}>{title}</Text>
  </View>
));

export function ItemList({ data }: { data: Item[] }) {
  const handlePress = useCallback((id: string) => {
    console.log('pressed', id);
  }, []);

  const renderItem = useCallback(
    ({ item }: { item: Item }) => (
      <ListItem title={item.title} onPress={() => handlePress(item.id)} />
    ),
    [handlePress]
  );

  return (
    <FlatList
      data={data}
      keyExtractor={(item) => item.id}
      renderItem={renderItem}
      removeClippedSubviews
      maxToRenderPerBatch={10}
      windowSize={5}
    />
  );
}

const styles = StyleSheet.create({
  item: { padding: 16, borderBottomWidth: StyleSheet.hairlineWidth },
});
KeyboardAvoidingView を使ったフォーム
import React from 'react';
import {
  KeyboardAvoidingView,
  Platform,
  ScrollView,
  TextInput,
  StyleSheet,
  SafeAreaView,
} from 'react-native';

export function LoginForm() {
  return (
    <SafeAreaView style={styles.safe}>
      <KeyboardAvoidingView
        style={styles.flex}
        behavior={Platform.OS === 'ios' ? 'padding' : 'height'}
      >
        <ScrollView contentContainerStyle={styles.content} keyboardShouldPersistTaps="handled">
          <TextInput style={styles.input} placeholder="Email" autoCapitalize="none" />
          <TextInput style={styles.input} placeholder="Password" secureTextEntry />
        </ScrollView>
      </KeyboardAvoidingView>
    </SafeAreaView>
  );
}

const styles = StyleSheet.create({
  safe: { flex: 1 },
  flex: { flex: 1 },
  content: { padding: 16, gap: 12 },
  input: { borderWidth: 1, borderRadius: 8, padding: 12, fontSize: 16 },
});
プラットフォーム固有のコンポーネント
import { Platform, StyleSheet, View, Text } from 'react-native';

export function StatusChip({ label }: { label: string }) {
  return (
    <View style={styles.chip}>
      <Text style={styles.label}>{label}</Text>
    </View>
  );
}

const styles = StyleSheet.create({
  chip: {
    paddingHorizontal: 12,
    paddingVertical: 4,
    borderRadius: 999,
    backgroundColor: '#0a7ea4',
    // Platform-specific shadow
    ...Platform.select({
      ios: { shadowColor: '#000', shadowOffset: { width: 0, height: 2 }, shadowOpacity: 0.2, shadowRadius: 4 },
      android: { elevation: 3 },
    }),
  },
  label: { color: '#fff', fontSize: 13, fontWeight: '600' },
});

出力形式

React Native の機能を実装する際は、次を提示してください。

  1. コンポーネントコード — TypeScript を使用し、プロパティ型を定義する
  2. プラットフォームごとの処理 — 必要に応じて Platform.select または .ios.tsx / .android.tsx に分割する
  3. ナビゲーションへの統合 — ルートパラメーターを型付けし、戻るボタンへの対応を含める
  4. パフォーマンスに関する注意点 — memo の適用範囲、キー抽出方法、画像キャッシュ

ナレッジリファレンス

React Native 0.73 以降、Expo SDK 50 以降、Expo Router、React Navigation 7、Reanimated 3、Gesture Handler、AsyncStorage、MMKV、React Query、Zustand

Synergetic Solutions のプリンシパルコンサルタント、@jeffallan がメンテナンスしています。

ドキュメント

コメント