expo-react-native-coder
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseExpo React Native Coder Best Practices
Expo React Native 开发者最佳实践
Comprehensive feature development guide for Expo React Native applications. Contains 50 rules across 10 categories, covering everything from project setup to testing. Includes production-ready code templates for common features.
这是一份针对Expo React Native应用的全面功能开发指南,涵盖从项目搭建到测试的10个类别共50条规则,包含适用于常见功能的生产级代码模板。
When to Apply
适用场景
Reference these guidelines when:
- Setting up a new Expo project with TypeScript
- Building navigation with Expo Router (tabs, stacks, drawers, modals)
- Creating screens (list, detail, form, settings)
- Implementing authentication flows with protected routes
- Configuring deep linking and universal links
在以下场景中可参考本指南:
- 使用TypeScript搭建新的Expo项目
- 利用Expo Router构建导航(标签页、栈、抽屉、模态框)
- 创建各类界面(列表页、详情页、表单页、设置页)
- 实现带受保护路由的身份验证流程
- 配置深度链接和通用链接
Rule Categories by Priority
按优先级划分的规则类别
| Priority | Category | Impact | Prefix |
|---|---|---|---|
| 1 | Project Setup & Configuration | CRITICAL | |
| 2 | Routing & Navigation | CRITICAL | |
| 3 | Screen Patterns & Layouts | HIGH | |
| 4 | Data Fetching & State | HIGH | |
| 5 | Authentication & Security | HIGH | |
| 6 | Deep Linking & Universal Links | HIGH | |
| 7 | Native UX Patterns | MEDIUM-HIGH | |
| 8 | Forms & User Input | MEDIUM | |
| 9 | Assets & Theming | MEDIUM | |
| 10 | Error Handling & Testing | MEDIUM | |
| 优先级 | 类别 | 影响程度 | 前缀 |
|---|---|---|---|
| 1 | 项目搭建与配置 | 关键 | |
| 2 | 路由与导航 | 关键 | |
| 3 | 界面模式与布局 | 高 | |
| 4 | 数据获取与状态管理 | 高 | |
| 5 | 身份验证与安全 | 高 | |
| 6 | 深度链接与通用链接 | 高 | |
| 7 | 原生UX模式 | 中高 | |
| 8 | 表单与用户输入 | 中 | |
| 9 | 资源与主题 | 中 | |
| 10 | 错误处理与测试 | 中 | |
Quick Reference
快速参考
1. Project Setup & Configuration (CRITICAL)
1. 项目搭建与配置(关键)
- - Configure TypeScript with strict mode
setup-typescript-config - - Use typed app.config.ts
setup-app-config-typescript - - EXPO_PUBLIC_ prefix for client vars
setup-environment-variables - - EAS build profiles per environment
setup-eas-build-profiles - - Development builds vs Expo Go
setup-development-build
- - 配置严格模式的TypeScript
setup-typescript-config - - 使用类型化的app.config.ts
setup-app-config-typescript - - 客户端变量使用EXPO_PUBLIC_前缀
setup-environment-variables - - 为不同环境配置EAS构建配置文件
setup-eas-build-profiles - - 开发构建与Expo Go的对比
setup-development-build
2. Routing & Navigation (CRITICAL)
2. 路由与导航(关键)
- - File-based routing with Expo Router
route-file-based-routing - - Tab navigator with route groups
route-tab-navigator - - Dynamic route segments [param]
route-dynamic-segments - - Nested stack in tabs
route-stack-within-tabs - - Modal screen presentation
route-modal-presentation - - Enable typed routes
route-typed-routes - - Drawer navigator setup
route-drawer-navigator
- - 使用Expo Router实现基于文件的路由
route-file-based-routing - - 带路由组的标签页导航器
route-tab-navigator - - 动态路由分段[param]
route-dynamic-segments - - 标签页中的嵌套栈
route-stack-within-tabs - - 模态界面展示
route-modal-presentation - - 启用类型化路由
route-typed-routes - - 抽屉导航器设置
route-drawer-navigator
3. Screen Patterns & Layouts (HIGH)
3. 界面模式与布局(高)
- - FlashList for large lists
screen-list-flashlist - - Pass minimal data via params
screen-detail-params - - Loading and error states
screen-loading-state - - Pull-to-refresh pattern
screen-pull-to-refresh - - Configure screen headers
screen-header-options - - Settings screen with SectionList
screen-settings-list
- - 使用FlashList处理大型列表
screen-list-flashlist - - 通过参数传递最小化数据
screen-detail-params - - 加载与错误状态处理
screen-loading-state - - 下拉刷新模式
screen-pull-to-refresh - - 配置界面头部选项
screen-header-options - - 使用SectionList实现设置界面
screen-settings-list
4. Data Fetching & State (HIGH)
4. 数据获取与状态管理(高)
- - Server-side API routes
data-api-routes - - SecureStore for sensitive data
data-secure-store - - SQLite for complex local data
data-sqlite-local - - Refetch on screen focus
data-fetch-on-focus - - AsyncStorage for preferences
data-async-storage-simple - - Cancel fetch on unmount
data-abort-controller
- - 服务端API路由
data-api-routes - - 使用SecureStore存储敏感数据
data-secure-store - - 使用SQLite处理复杂本地数据
data-sqlite-local - - 界面获取焦点时重新获取数据
data-fetch-on-focus - - 使用AsyncStorage存储偏好设置
data-async-storage-simple - - 组件卸载时取消请求
data-abort-controller
5. Authentication & Security (HIGH)
5. 身份验证与安全(高)
- - Stack.Protected guards
auth-protected-routes - - Auth context with session
auth-context-provider - - OAuth with AuthSession
auth-oauth-flow - - Login form with validation
auth-login-form - - Splash screen during auth check
auth-splash-loading
- - 使用Stack.Protected守卫
auth-protected-routes - - 带会话的身份验证上下文
auth-context-provider - - 使用AuthSession实现OAuth流程
auth-oauth-flow - - 带验证的登录表单
auth-login-form - - 身份验证检查时的启动屏
auth-splash-loading
6. Deep Linking & Universal Links (HIGH)
6. 深度链接与通用链接(高)
- - Custom URL scheme
link-deep-linking-scheme - - iOS Universal Links
link-universal-links-ios - - Android App Links
link-android-app-links - - Handle incoming URLs
link-handle-incoming
- - 自定义URL协议
link-deep-linking-scheme - - iOS通用链接
link-universal-links-ios - - Android应用链接
link-android-app-links - - 处理传入的URL
link-handle-incoming
7. Native UX Patterns (MEDIUM-HIGH)
7. 原生UX模式(中高)
- - SafeAreaView for notches
ux-safe-area-insets - - Status bar styling
ux-status-bar - - Haptic feedback on actions
ux-haptic-feedback - - Gesture handler for swipes
ux-gesture-handler - - KeyboardAvoidingView
ux-keyboard-avoiding
- - 使用SafeAreaView适配刘海屏
ux-safe-area-insets - - 状态栏样式设置
ux-status-bar - - 操作时的触觉反馈
ux-haptic-feedback - - 滑动操作的手势处理器
ux-gesture-handler - - 使用KeyboardAvoidingView
ux-keyboard-avoiding
8. Forms & User Input (MEDIUM)
8. 表单与用户输入(中)
- - TextInput keyboard types
form-text-input-config - - Controlled inputs with useState
form-controlled-inputs - - Disable button during submit
form-submit-button-state - - Dismiss keyboard on tap outside
form-dismiss-keyboard
- - TextInput键盘类型配置
form-text-input-config - - 使用useState实现受控输入
form-controlled-inputs - - 提交过程中禁用按钮
form-submit-button-state - - 点击外部时收起键盘
form-dismiss-keyboard
9. Assets & Theming (MEDIUM)
9. 资源与主题(中)
- - expo-image for caching
asset-image-optimization - - Load fonts with useFonts
asset-font-loading - - @expo/vector-icons
asset-vector-icons - - Splash screen configuration
asset-splash-screen
- - 使用expo-image实现缓存
asset-image-optimization - - 使用useFonts加载字体
asset-font-loading - - @expo/vector-icons使用
asset-vector-icons - - 启动屏配置
asset-splash-screen
10. Error Handling & Testing (MEDIUM)
10. 错误处理与测试(中)
- - Jest with jest-expo preset
test-jest-setup - - Testing Library for components
test-component-testing - - Error boundaries
test-error-boundary - - Maestro E2E testing
test-e2e-maestro
- - 使用jest-expo预设配置Jest
test-jest-setup - - 使用Testing Library测试组件
test-component-testing - - 错误边界实现
test-error-boundary - - 使用Maestro进行端到端测试
test-e2e-maestro
Code Templates
代码模板
Production-ready templates are available in :
assets/templates/| Template | Description |
|---|---|
| Bottom tab navigator with icons |
| Root layout with protected routes |
| List with FlashList, refresh, states |
| Detail screen with param handling |
| Form with validation, keyboard handling |
| Auth context with SecureStore |
| Error boundary component |
生产级模板可在目录下找到:
assets/templates/| 模板 | 描述 |
|---|---|
| 带图标的底部标签页导航器 |
| 带受保护路由的根布局 |
| 包含FlashList、刷新、状态的列表页 |
| 处理参数的详情页 |
| 带验证、键盘处理的表单页 |
| 集成SecureStore的身份验证上下文 |
| 错误边界组件 |
How to Use
使用方法
Read individual reference files for detailed explanations and code examples:
- Section definitions - Category structure and impact levels
- Rule template - Template for adding new rules
阅读单个参考文件获取详细说明和代码示例:
- 章节定义 - 类别结构与影响级别
- 规则模板 - 添加新规则的模板
Full Compiled Document
完整编译文档
For a single comprehensive document with all rules, see AGENTS.md.
如需包含所有规则的单一综合文档,请查看AGENTS.md。
Reference Files
参考文件
| File | Description |
|---|---|
| AGENTS.md | Complete compiled guide with all rules |
| references/_sections.md | Category definitions and ordering |
| assets/templates/ | Production-ready code templates |
| metadata.json | Version and reference information |
| 文件 | 描述 |
|---|---|
| AGENTS.md | 包含所有规则的完整编译指南 |
| references/_sections.md | 类别定义与排序 |
| assets/templates/ | 生产级代码模板 |
| metadata.json | 版本与参考信息 |