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 步骤以及避免常见陷阱。它支持从任一旧版本升级到任一新版本,并特别强调与 Expo 项目的兼容性。技能核心是引导用户通过一系列子文档按顺序执行:先选择升级路径,再获取差异文件,然后更新第三方依赖和 React 版本,接着处理 Expo SDK 层(如果适用),最后运行升级后验证。该技能适用于 React Native 应用的版本升级,能够自动检测当前版本并获取对应的模板差异,手动或借助 IDE 辅助完成文件变更应用、依赖安装和编译验证。它还提供了详细的快速参考表格,将不同问题(如需要依赖风险评估、需要 React 版本对齐等)映射到具体的子文档。

兼容平台~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.md 对齐 React 版本
  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.

相关技能