vercel-react-native-skills
对比查看原文与翻译
🇺🇸
原文
英文🇨🇳
翻译
中文React Native Skills
React Native 实践技巧
Comprehensive best practices for React Native and Expo applications. Contains
rules across multiple categories covering performance, animations, UI patterns,
and platform-specific optimizations.
为React Native和Expo应用提供的全面最佳实践。涵盖性能、动画、UI模式和平台特定优化等多个类别的规则。
When to Apply
适用场景
Reference these guidelines when:
- Building React Native or Expo apps
- Optimizing list and scroll performance
- Implementing animations with Reanimated
- Working with images and media
- Configuring native modules or fonts
- Structuring monorepo projects with native dependencies
在以下场景中参考这些指南:
- 构建React Native或Expo应用
- 优化列表和滚动性能
- 使用Reanimated实现动画
- 处理图片和媒体资源
- 配置原生模块或字体
- 构建包含原生依赖的单仓库(Monorepo)项目
Rule Categories by Priority
按优先级划分的规则类别
| Priority | Category | Impact | Prefix |
|---|---|---|---|
| 1 | List Performance | CRITICAL | |
| 2 | Animation | HIGH | |
| 3 | Navigation | HIGH | |
| 4 | UI Patterns | HIGH | |
| 5 | State Management | MEDIUM | |
| 6 | Rendering | MEDIUM | |
| 7 | Monorepo | MEDIUM | |
| 8 | Configuration | LOW | |
| 优先级 | 类别 | 影响程度 | 前缀 |
|---|---|---|---|
| 1 | 列表性能 | 关键 | |
| 2 | 动画 | 高 | |
| 3 | 导航 | 高 | |
| 4 | UI模式 | 高 | |
| 5 | 状态管理 | 中 | |
| 6 | 渲染 | 中 | |
| 7 | 单仓库(Monorepo) | 中 | |
| 8 | 配置 | 低 | |
Quick Reference
快速参考
1. List Performance (CRITICAL)
1. 列表性能(关键)
- - Use FlashList for large lists
list-performance-virtualize - - Memoize list item components
list-performance-item-memo - - Stabilize callback references
list-performance-callbacks - - Avoid inline style objects
list-performance-inline-objects - - Extract functions outside render
list-performance-function-references - - Optimize images in lists
list-performance-images - - Move expensive work outside items
list-performance-item-expensive - - Use item types for heterogeneous lists
list-performance-item-types
- - 对大型列表使用FlashList
list-performance-virtualize - - 对列表项组件进行Memo化处理
list-performance-item-memo - - 稳定回调引用
list-performance-callbacks - - 避免内联样式对象
list-performance-inline-objects - - 在渲染外部提取函数
list-performance-function-references - - 优化列表中的图片
list-performance-images - - 将耗时操作移出列表项
list-performance-item-expensive - - 对异构列表使用项类型
list-performance-item-types
2. Animation (HIGH)
2. 动画(高)
- - Animate only transform and opacity
animation-gpu-properties - - Use useDerivedValue for computed animations
animation-derived-value - - Use Gesture.Tap instead of Pressable
animation-gesture-detector-press
- - 仅对transform和opacity属性执行动画
animation-gpu-properties - - 使用useDerivedValue实现计算式动画
animation-derived-value - - 使用Gesture.Tap替代Pressable
animation-gesture-detector-press
3. Navigation (HIGH)
3. 导航(高)
- - Use native stack and native tabs over JS navigators
navigation-native-navigators
- - 使用原生栈和原生标签导航器替代JS导航器
navigation-native-navigators
4. UI Patterns (HIGH)
4. UI模式(高)
- - Use expo-image for all images
ui-expo-image - - Use Galeria for image lightboxes
ui-image-gallery - - Use Pressable over TouchableOpacity
ui-pressable - - Handle safe areas in ScrollViews
ui-safe-area-scroll - - Use contentInset for headers
ui-scrollview-content-inset - - Use native context menus
ui-menus - - Use native modals when possible
ui-native-modals - - Use onLayout, not measure()
ui-measure-views - - Use StyleSheet.create or Nativewind
ui-styling
- - 对所有图片使用expo-image
ui-expo-image - - 使用Galeria实现图片灯箱
ui-image-gallery - - 使用Pressable替代TouchableOpacity
ui-pressable - - 在ScrollViews中处理安全区域
ui-safe-area-scroll - - 对头部使用contentInset
ui-scrollview-content-inset - - 使用原生上下文菜单
ui-menus - - 尽可能使用原生模态框
ui-native-modals - - 使用onLayout而非measure()
ui-measure-views - - 使用StyleSheet.create或Nativewind
ui-styling
5. State Management (MEDIUM)
5. 状态管理(中)
- - Minimize state subscriptions
react-state-minimize - - Use dispatcher pattern for callbacks
react-state-dispatcher - - Show fallback on first render
react-state-fallback - - Destructure for React Compiler
react-compiler-destructure-functions - - Handle shared values with compiler
react-compiler-reanimated-shared-values
- - 减少状态订阅
react-state-minimize - - 对回调使用调度器模式
react-state-dispatcher - - 在首次渲染时显示回退内容
react-state-fallback - - 为React Compiler进行解构
react-compiler-destructure-functions - - 配合编译器处理共享值
react-compiler-reanimated-shared-values
6. Rendering (MEDIUM)
6. 渲染(中)
- - Wrap text in Text components
rendering-text-in-text-component - - Avoid falsy && for conditional rendering
rendering-no-falsy-and
- - 将文本包裹在Text组件中
rendering-text-in-text-component - - 避免使用falsy &&进行条件渲染
rendering-no-falsy-and
7. Monorepo (MEDIUM)
7. 单仓库(Monorepo)(中)
- - Keep native dependencies in app package
monorepo-native-deps-in-app - - Use single versions across packages
monorepo-single-dependency-versions
- - 将原生依赖保留在应用包中
monorepo-native-deps-in-app - - 在所有包中使用统一的依赖版本
monorepo-single-dependency-versions
8. Configuration (LOW)
8. 配置(低)
- - Use config plugins for custom fonts
fonts-config-plugin - - Organize design system imports
imports-design-system-folder - - Hoist Intl object creation
js-hoist-intl
- - 使用配置插件处理自定义字体
fonts-config-plugin - - 组织设计系统的导入
imports-design-system-folder - - 提升Intl对象创建
js-hoist-intl
How to Use
使用方法
Read individual rule files for detailed explanations and code examples:
rules/list-performance-virtualize.md
rules/animation-gpu-properties.mdEach rule file contains:
- Brief explanation of why it matters
- Incorrect code example with explanation
- Correct code example with explanation
- Additional context and references
阅读单个规则文件获取详细说明和代码示例:
rules/list-performance-virtualize.md
rules/animation-gpu-properties.md每个规则文件包含:
- 规则重要性的简要说明
- 错误代码示例及解释
- 正确代码示例及解释
- 额外背景信息和参考资料
Full Compiled Document
完整编译文档
For the complete guide with all rules expanded:
AGENTS.md如需查看包含所有扩展规则的完整指南:
AGENTS.md