Community程式設計與開發github.com

升級 React Native

透過套用 rn-diff-purge 範本差異、更新 package.json 相依套件、遷移原生 iOS 和 Android 配置、解決 CocoaPods 和 Gradle 變更,以及處理破壞性 API 更新,將 React Native 應用程式升級至較新版本。適用於升級 React Native、提高 RN 版本號、從 RN 0.x 升級至 0.y,或是在 React Native 升級的同時遷移 Expo SDK。

升級 React Native 是什麼?

此技能完整涵蓋 React Native 升級流程,包括透過 Upgrade Helper 套用範本差異、更新相依套件、處理 Expo SDK 步驟以及常見陷阱。它建構在一個逐步的工作流程上,首先選擇正確的升級路徑,然後獲取官方範本差異,評估並遷移第三方套件,對齊 React 版本,如有需要則套用 Expo SDK 層,最後執行升級後驗證。 該技能設計用於與 Cursor 等 AI 代理平台協作,提供一系列參考文件路由,涵蓋相依性風險評估、React 19 遷移規則、Expo SDK 特定步驟以及代理輔助回歸驗證。它也支援單一儲存庫和單一儲存庫的應用程式定位。透過引用可執行的 CLI 範例(如 curl、npm install、pod install 和 xcodebuild),此技能可作為在 CI/CD 或本地開發環境中升級 RN 的實作指南。

相容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/callstackincubator/agent-skills/tree/main/skills/upgrading-react-native

Installed? Explore more 程式設計與開發 skills: steipete/bluebubbles, steipete/eightctl, steipete/blucli · View all 6 →

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

升級 React Native 是做什麼的?

概述

涵蓋完整的 React Native 升級工作流程:透過 Upgrade Helper 的範本差異、相依套件更新、Expo SDK 步驟以及常見陷阱。

典型升級順序

  1. 路由:透過 upgrading-react-native.md 選擇正確的升級路徑
  2. 差異:使用 Upgrade Helper 經由 upgrade-helper-core.md 獲取官方範本差異
  3. 相依套件:透過 upgrading-dependencies.md 評估並更新第三方套件
  4. React:若升級 React,透過 react.md 對齊版本
  5. Expo(如適用):經由 expo-sdk-upgrade.md 套用 Expo SDK 層
  6. 驗證:透過 upgrade-verification.md 執行升級後檢查
# 快速開始:偵測目前版本並取得差異
npm pkg get dependencies.react-native --prefix "$APP_DIR"
npm view react-native dist-tags.latest

# 範例:從 0.76.9 升級至 0.78.2
# 1. 獲取範本差異
curl -L -f -o /tmp/rn-diff.diff \
  "https://raw.githubusercontent.com/react-native-community/rn-diff-purge/diffs/diffs/0.76.9..0.78.2.diff" \
  && echo "差異下載成功" || echo "錯誤:找不到差異,請檢查版本"
# 2. 檢視已變更的檔案
grep -n "^diff --git" /tmp/rn-diff.diff
# 3. 更新 package.json,套用原生變更,然後安裝並重建
npm install --prefix "$APP_DIR"
cd "$APP_DIR/ios" && pod install
# 4. 驗證:兩個平台都必須建置成功
npx react-native build-android --mode debug --no-packager
xcodebuild -workspace "$APP_DIR/ios/App.xcworkspace" -scheme App -sdk iphonesimulator build

何時套用

在以下情況參考這些指南:

  • 將 React Native 應用程式移至較新版本
  • 調和來自 Upgrade Helper 的原生配置變更
  • 驗證發行說明中的破壞性變更

快速參考

檔案說明
upgrading-react-native.md路由:選擇正確的升級路徑
upgrade-helper-core.md核心 Upgrade Helper 工作流程與可靠性閘道
upgrading-dependencies.md相依套件相容性檢查與遷移規劃
react.mdReact 與 React 19 升級對齊規則
expo-sdk-upgrade.mdExpo SDK 特定升級層(條件性)
upgrade-verification.md升級後驗證檢查清單,包含代理輔助檢查
monorepo-singlerepo-targeting.md單一儲存庫與單一儲存庫應用程式定位及命令範圍設定

問題 → 技能映射

問題從此開始
需要升級 React Nativeupgrade-helper-core.md
需要相依套件風險分類與遷移選項upgrading-dependencies.md
需要 React/React 19 套件對齊react.md
需要先進行工作流程路由upgrading-react-native.md
需要 Expo SDK 特定步驟expo-sdk-upgrade.md
需要手動或代理輔助回歸驗證upgrade-verification.md
需要儲存庫/應用程式命令範圍設定monorepo-singlerepo-targeting.md

Individual skills in this repo

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

agent-device

Automates interactions for Apple-platform apps (iOS, tvOS, macOS) and Android devices. Use when navigating apps, taking snapshots/screenshots, tapping, typing, scrolling, or extracting UI info across mobile, TV, and desktop targets.

assess-react-native-migration

Assesses whether and how an existing mobile product should migrate to React Native. Use when auditing one or more product repositories for migration readiness, including products whose iOS, Android, and other clients live in separate directories or repositories; choosing brownfield, greenfield, or a checkpoint-based path; defining a representative trial; or preparing a baseline and ROI decision before implementation. When product scope or material evidence is unavailable, grills the stakeholder with exactly one question per turn instead of sending a questionnaire.

callstackincubator/github

GitHub patterns using gh CLI for pull requests, stacked PRs, code review, branching strategies, and repository automation. Use when working with GitHub PRs, merging strategies, or repository management tasks.

callstackincubator/validate-skills

Validates skills in this repo against agentskills.io spec and Claude Code best practices. Use via /validate-skills command.

create-react-native-library

Scaffolds React Native libraries with create-react-native-library for standalone libraries or local native modules and views. Use when creating or working on React Native libraries or adding native functionality in an existing app.

dogfood

Systematically explore and test a mobile app on iOS/Android with agent-device to find bugs, UX issues, and other problems. Use when asked to "dogfood", "QA", "exploratory test", "find issues", "bug hunt", or "test this app" on mobile. Produces a structured report with reproducible evidence: screenshots, optional repro videos, and detailed steps for every issue.

github-actions

GitHub Actions workflow patterns for React Native iOS simulator and Android emulator cloud builds with downloadable artifacts. Use when setting up CI build pipelines or downloading GitHub Actions artifacts via gh CLI and GitHub API.

react-native-best-practices

Provides React Native performance optimization guidelines for FPS, TTI, bundle size, memory leaks, re-renders, and animations. Applies to tasks involving Hermes optimization, JS thread blocking, bridge overhead, FlashList, native modules, or debugging jank and frame drops.

react-native-brownfield-migration

Implements an accepted incremental brownfield migration from native iOS or Android to React Native or Expo using @callstack/react-native-brownfield. Use after the brownfield path has been selected, when setting up the integration, packaging XCFramework or AAR artifacts, or adding React Native surfaces to native hosts.

react-native-testing

Write tests using React Native Testing Library (RNTL) v13 and v14 (`@testing-library/react-native`). Use when writing, reviewing, or fixing React Native component tests. Covers: render, screen, queries (getBy/getAllBy/queryBy/findBy), Jest matchers, userEvent, fireEvent, waitFor, and async patterns. Supports v13 (React 18, sync render) and v14 (React 19+, async render). Triggers on: test files for React Native components, RNTL imports, mentions of "testing library", "write tests", "component tests", or "RNTL".

react-native-tv-best-practices

Reviews React Native TV apps for focus/D-pad navigation, 10-foot UI layout, TV playback/DRM integration, low-memory TV performance, and TV accessibility. Use when building, debugging, or reviewing react-native-tvos, Expo TV, Amazon Vega/Kepler, or React Native web TV targets where the issue depends on remote input, TV focus, TV packaging, TV hardware, or TV playback constraints.

react-navigation

Provides React Navigation UI patterns for stacks, tabs, drawers etc. Use when building navigation UIs with React Navigation, configuring headers, bottom sheets or handling safe areas and insets.

validate-skills

Validates skills in this repo against agentskills.io spec and Claude Code best practices. Use via /validate-skills command.

vercel-react-native-skills

React Native and Expo best practices for building performant mobile apps. Use when building React Native components, optimizing list performance, implementing animations, or working with native modules. Triggers on tasks involving React Native, Expo, mobile performance, or native platform APIs.

writing-user-docs

House style for user-facing documentation — voice, scope, structure, and what to leave out. Use this skill whenever writing, editing, or reviewing anything a user reads to learn how to use a tool — help center articles, getting-started guides, tutorials, feature docs, README usage sections, in-app help, release notes, or FAQ entries. Trigger it even when the request is phrased plainly — "document this feature", "write docs for X", "explain this to users", "write a README for this library", "turn these notes into a guide" — and even when no style guidelines are mentioned. Also use it to review existing docs for tone, bloat, or leaked implementation detail. Do not use it for internal engineering docs, architecture write-ups, RFCs, or code comments.

相關技能