Official编程与开发github.com

React Native 技能包

React Native 和 Expo 的最佳实践,用于构建高性能移动应用。

React Native 技能包 是什么?

这份技能包提供了全面的 React Native 和 Expo 应用最佳实践指南,涵盖性能、动画、UI 模式、状态管理、渲染、Monorepo 配置等多个类别。它针对常见性能瓶颈(如列表性能、动画优化)给出了具体规则和建议,并支持 FlashList、Reanimated、NativeWind 等现代工具。技能包按优先级(从关键到低)组织规则,每个规则都有详细的代码示例和解释,适合用于 Claude Code、Cursor 等 AI 编程助手,帮助开发者高效编写高质量的 React Native 代码。

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

Installed? Explore more 编程与开发 skills: steipete/bluebubbles, steipete/eightctl, steipete/blucli · View all 6 →

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

React Native 技能包 是做什么的?

React Native 和 Expo 应用的全面最佳实践。包含多个类别的规则,涵盖性能、动画、UI 模式和平台特定优化。

何时使用

在以下情况下参考这些指南:

  • 构建 React Native 或 Expo 应用
  • 优化列表和滚动性能
  • 使用 Reanimated 实现动画
  • 处理图片和媒体
  • 配置原生模块或字体
  • 组织包含原生依赖的 Monorepo 项目

按优先级分类的规则

优先级类别影响前缀
1列表性能严重list-performance-
2动画高animation-
3导航高navigation-
4UI 模式高ui-
5状态管理中react-state-
6渲染中rendering-
7Monorepo中monorepo-
8配置低fonts-, imports-

快速参考

1. 列表性能(严重)

  • list-performance-virtualize - 对于大型列表使用 FlashList
  • list-performance-item-memo - 对列表项组件使用 memo
  • list-performance-callbacks - 稳定回调引用
  • list-performance-inline-objects - 避免内联样式对象
  • list-performance-function-references - 将函数提取到 render 外部
  • list-performance-images - 优化列表中的图片
  • list-performance-item-expensive - 将耗时操作移到列表项外部
  • list-performance-item-types - 对异构列表使用 item 类型

2. 动画(高)

  • animation-gpu-properties - 仅对 transform 和 opacity 做动画
  • animation-derived-value - 使用 useDerivedValue 进行计算的动画
  • animation-gesture-detector-press - 使用 Gesture.Tap 代替 Pressable

3. 导航(高)

  • navigation-native-navigators - 使用原生 Stack 和原生 Tabs 代替 JS 导航器

4. UI 模式(高)

  • ui-expo-image - 对所有图片使用 expo-image
  • ui-image-gallery - 使用 Galeria 实现图片灯箱
  • ui-pressable - 使用 Pressable 代替 TouchableOpacity
  • ui-safe-area-scroll - 在 ScrollView 中处理安全区域
  • ui-scrollview-content-inset - 对头部使用 contentInset
  • ui-menus - 使用原生上下文菜单
  • ui-native-modals - 尽可能使用原生模态框
  • ui-measure-views - 使用 onLayout,而不是 measure()
  • ui-styling - 使用 StyleSheet.create 或 Nativewind

5. 状态管理(中)

  • react-state-minimize - 最小化状态订阅
  • react-state-dispatcher - 对回调使用 dispatcher 模式
  • react-state-fallback - 在首次渲染时显示 fallback
  • react-compiler-destructure-functions - 为 React Compiler 解构函数
  • react-compiler-reanimated-shared-values - 处理与编译器共用的 shared values

6. 渲染(中)

  • rendering-text-in-text-component - 将文本包裹在 Text 组件中
  • rendering-no-falsy-and - 避免使用 falsy && 进行条件渲染

7. Monorepo(中)

  • monorepo-native-deps-in-app - 将原生依赖保留在应用包中
  • monorepo-single-dependency-versions - 在所有包中使用单一版本

8. 配置(低)

  • fonts-config-plugin - 使用配置插件处理自定义字体
  • imports-design-system-folder - 组织设计系统导入
  • js-hoist-intl - 提升 Intl 对象的创建

使用方法

阅读单个规则文件以获取详细说明和代码示例:

rules/list-performance-virtualize.md
rules/animation-gpu-properties.md

每个规则文件包含:

  • 为何重要的简要说明
  • 错误代码示例及解释
  • 正确代码示例及解释
  • 额外的上下文和参考

完整文档

如需所有规则展开的完整指南,请参阅:AGENTS.md

Individual skills in this repo

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

deploy-to-vercel

Deploy applications and websites to Vercel. Use when the user requests deployment actions like "deploy my app", "deploy and give me the link", "push this live", or "create a preview deployment".

vercel-cli-with-tokens

Deploy and manage projects on Vercel using token-based authentication. Use when working with Vercel CLI using access tokens rather than interactive login — e.g.

vercel-composition-patterns

React composition patterns that scale. Use when refactoring components with

vercel-labs/vercel-composition-patterns

React composition patterns that scale. Use when refactoring components with boolean prop proliferation, building flexible component libraries, or designing reusable APIs. Triggers on tasks involving compound components, render props, context providers, or component architecture. Includes React 19 API changes.

vercel-labs/vercel-react-best-practices

React and Next.js performance optimization guidelines from Vercel Engineering. This skill should be used when writing, reviewing, or refactoring React/Next.js code to ensure optimal performance patterns. Triggers on tasks involving React components, Next.js pages, data fetching, bundle optimization, or performance improvements.

vercel-labs/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.

vercel-labs/vercel-react-view-transitions

Guide for implementing smooth, native-feeling animations using React's View Transition API (`<ViewTransition>` component, `addTransitionType`, and CSS view transition pseudo-elements). Use this skill whenever the user wants to add page transitions, animate route changes, create shared element animations, animate enter/exit of components, animate list reorder, implement directional (forward/back) navigation animations, or integrate view transitions in Next.js. Also use when the user mentions view transitions, `startViewTransition`, `ViewTransition`, transition types, or asks about animating between UI states in React without third-party animation libraries.

vercel-optimize

Use for Vercel cost and performance optimization on deployed projects, especially Next.js, SvelteKit, Nuxt, and limited Astro apps. Collect Vercel metrics, usage, project config, and code scan results first; investigate only metric-backed candidates; produce ranked recommendations grounded in verified files and version-aware Vercel/framework docs. Trigger for Vercel bill reduction, slow or expensive routes, caching opportunities, Function Invocations, Build Minutes, Fast Data Transfer, Core Web Vitals, Bot Management, Fluid compute, or cost breakdown requests.

vercel-react-best-practices

React and Next.js performance optimization guidelines from Vercel Engineering. This skill should be used when writing, reviewing, or refactoring React/Next.js code to ensure optimal performance patterns. Triggers on tasks involving React components, Next.js pages, data fetching, bundle optimization, or performance improvements.

web-design-guidelines

Review UI code for Web Interface Guidelines compliance. Use when asked to

writing-guidelines

Review docs/prose for Writing Guidelines compliance. Use when asked to

相关技能