upgrading-react-native

upgrading-react-native

熱門

透過套用 rn-diff-purge 範本差異(diff)、更新 package.json 相依套件、轉移 iOS 與 Android 原生設定、處理 CocoaPods 與 Gradle 變更,以及應對 API 破壞性更新,將 React Native 應用程式升級至新版本。適用於升級 React Native、提升 RN 版本、從 RN 0.x 更新至 0.y,或在升級 React Native 的同時轉移 Expo SDK。

1534星標
109分支
更新於 2026/7/10
SKILL.md
唯讀
名稱
upgrading-react-native
描述

透過套用 rn-diff-purge 範本差異(diff)、更新 package.json 相依套件、轉移 iOS 與 Android 原生設定、處理 CocoaPods 與 Gradle 變更,以及應對 API 破壞性更新,將 React Native 應用程式升級至新版本。適用於升級 React Native、提升 RN 版本、從 RN 0.x 更新至 0.y,或在升級 React Native 的同時轉移 Expo SDK。

Upgrading React Native

Overview

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

Typical Upgrade Sequence

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

# 範例:從 0.76.9 升級至 0.78.2
# 1. 下載範本 diff
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 "Diff downloaded OK" || echo "ERROR: diff not found, check versions"
# 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

When to Apply

在以下情境時參考本指南:

  • 將 React Native 應用程式升級至較新版本
  • 整合並對照 Upgrade Helper 的原生設定變更
  • 查閱 Release Notes 以確認破壞性變更(Breaking Changes)

Quick Reference

File Description
upgrading-react-native.md 路由指引:選擇正確的升級路徑
upgrade-helper-core.md 核心 Upgrade Helper 工作流程與可靠性檢查門檻
upgrading-dependencies.md 相依套件相容性檢查與轉移規劃
react.md React 與 React 19 升級版本對齊規則
expo-sdk-upgrade.md Expo SDK 專用升級層(條件式)
upgrade-verification.md 升級後驗證檢查清單,包含 Agent / 裝置輔助檢查
monorepo-singlerepo-targeting.md Monorepo 與 Single-repo 的應用程式定位及指令作用域

Problem → Skill Mapping

Problem Start With
需要升級 React Native upgrade-helper-core.md
需要評估套件相依性風險與轉移方案 upgrading-dependencies.md
需要對齊 React / React 19 套件版本 react.md
需要先進行工作流程路由 upgrading-react-native.md
需要 Expo SDK 專用步驟 expo-sdk-upgrade.md
需要手動或 Agent 輔助的回歸測試驗證 upgrade-verification.md
需要指定專案/應用程式的指令執行作用域 monorepo-singlerepo-targeting.md