反应原生架构
- 作者仓库星标 36,312
- 作者仓库 agents
- 领域
- 工程开发
- 作者声明的智能体
- 未找到明确声明;不据此推断已兼容或已测试
- 静态检查
- 88 / 100 · 启发式扫描,不代表运行安全
- 运行环境证据
- 未执行;当前没有隔离运行测试证据
- 作者 / 版本 / 许可证
- @wshobson · 未声明许可证
- 上下文用量评级
- 低消耗
- 接入复杂程度
- 即装即用
- 是否需要外部接口密钥
- 不需要
- 兼容的系统
- macOS · Linux · Windows
- 运行环境要求
- 未检出明确要求
- 检测到的文件与系统行为
-
- 只读
- 允许写入 / 修改
- 读取环境变量
- 网络行为
- 允许外网请求
- 安装命令数
- 无(仅作为资料)
需要注意: 未声明工具权限范围;实际权限由运行环境决定。
# Create new Expo project
npx create-expo-app@latest my-app -t expo-template-blank-typescript
# Install essential dependencies
npx expo install expo-router expo-status-bar react-native-safe-area-context
npx expo install @react-native-async-storage/async-storage
npx expo install expo-secure-store expo-haptics
# React Native Architecture
Production-ready patterns for React Native development with Expo, including navigation, state management, native modules, and offline-first architecture.
## When to Use This Skill
- Starting a new React Native or Expo project
- Implementing complex navigation patterns
- Integrating native modules and platform APIs
- Building offline-first mobile applications
- Optimizing React Native performance
- Setting up CI/CD for mobile releases
## Core Concepts
### 1. Project Structure
```
src/
├── app/ # Expo Router screens
│ ├── (auth)/ # Auth group
│ ├── (tabs)/ # Tab navigation
│ └── _layout.tsx # Root layout
├── components/
│ ├── ui/ # Reusable UI components
│ └── features/ # Feature-specific components
├── hooks/ # Custom hooks
├── services/ # API and native services
├── stores/ # State management
├── utils/ # Utilities
└── types/ # TypeScript types
```
### 2. Expo vs Bare React Native
| Feature | Expo | Bare RN |
| ------------------ | -------------- | -------------- |
| Setup complexity | Low | High |
| Native modules | EAS Build | Manual linking |
| OTA updates | Built-in | Manual setup |
| Build service | EAS | Custom CI |
| Custom native code | Config plugins | Direct access |
## Quick Start
```bash
# Create new Expo project
npx create-expo-app@latest my-app -t expo-template-blank-typescript
# Install essential dependencies
npx expo install expo-router expo-status-bar react-native-safe-area-context
npx expo install @react-native-async-storage/async-storage
npx expo install expo-secure-store expo-haptics
```
```typescript
// app/_layout.tsx
import { Stack } from 'expo-router'
import { ThemeProvider } from '@/providers/ThemeProvider'
import { QueryProvider } from '@/providers/QueryProvider'
export default function RootLayout() {
return (
<QueryProvider>
<ThemeProvider>
<Stack screenOptions={{ headerShown: false }}>
<Stack.Screen name="(tabs)" />
<Stack.Screen name="(auth)" />
<Stack.Screen name="modal" options={{ presentation: 'modal' }} />
</Stack>
</ThemeProvider>
</QueryProvider>
)
}
```
## Detailed patterns and worked examples
Detailed pattern documentation lives in `references/details.md`. Read that file when the navigation tier above is insufficient.
## Best Practices
### Do's
- **Use Expo** - Faster development, OTA updates, managed native code
- **FlashList over FlatList** - Better performance for long lists
- **Memoize components** - Prevent unnecessary re-renders
- **Use Reanimated** - 60fps animations on native thread
- **Test on real devices** - Simulators miss real-world issues
### Don'ts
- **Don't inline styles** - Use StyleSheet.create for performance
- **Don't fetch in render** - Use useEffect or React Query
- **Don't ignore platform differences** - Test on both iOS and Android
- **Don't store secrets in code** - Use environment variables
- **Don't skip error boundaries** - Mobile crashes are unforgiving
章节与文件索引
按说明文件中的顺序排列。
何时使用此技能
2. Expo 与 Bare React Native
详细的模式和工作示例
要做的事
不该做的事
文件/命令 -> references/details.md · CI/CD · _layout.ts · react-native-async-storage/async-storage · app/_layout.tsx · providers/ThemeProvider · providers/QueryProvider
内容校验值 -> 7e2c996a4c56
当前原文的自动摘译,尚未人工审校。
何时使用此技能
启动新的 React Native 或 Expo 项目 实现复杂的导航模式 集成本机模块和平台 API 构建离线优先的移动应用程序 优化 React Native 性能
2. Expo 与 Bare React Native
功能 · 博览会 · 裸 RN 设置复杂度 · 低 · 高原生模块 · EAS 构建 · 手动链接 OTA 更新 · 内置 · 手动设置 构建服务 · EAS · 自定义 CI
详细的模式和工作示例
详细的模式文档位于
references/details.md。当上面的导航层不够时,请阅读该文件。要做的事
使用 Expo - 更快的开发、OTA 更新、托管本机代码 FlashList 优于 FlatList - 长列表的性能更好 Memoize 组件 - 防止不必要的重新渲染 使用 Reanimated - 本机线程上的 60fps 动画 在真实设备上测试 - 模拟器会错过现实世界的问题
不该做的事
不要内联样式 - 使用 StyleSheet.create 来提高性能 不要在渲染中获取 - 使用 useEffect 或 React Query 不要忽略平台差异 - 在 iOS 和 Android 上进行测试 不要在代码中存储秘密 - 使用环境变量 不要跳过错误边界 - 移动崩溃是不可原谅的