react-native-architecture
它能做什么
这个技能可以帮你使用 React Native 和 Expo 开发移动应用。它提供了一套现成的项目结构,包括代码组织方式、页面导航,以及离线访问等功能。
适用场景
- ✓开始一个新的移动应用项目时。
- ✓当你需要一种有条理的方式在应用页面之间切换时。
- ✓如果应用需要在没有网络连接的情况下也能正常使用。
技能链接
https://github.com/wshobson/agents/blob/main/plugins/frontend-mobile-development/skills/react-native-architecture/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“我该如何为新的 React Native 应用组织代码?”
每周 5 个新技能,1 分钟读完。
工作原理
这个技能会建议一套文件夹结构,帮你整理应用的代码。它还会展示如何设置页面导航,并提供一些技巧,让应用即使在离线状态下也能保持良好的性能。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
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
# 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
// 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
常见问题
什么是 Expo?
Expo 是一个工具,它会帮你处理许多复杂的配置,从而简化 React Native 应用的开发过程。
“离线优先”(offline-first)是什么意思?
意思是应用在设计上就支持用户没有网络连接时仍能使用,数据会先存储在本地,之后再同步。
我需要会 Swift 或 Kotlin 这类原生编程吗?
一般不需要。Expo 和 React Native 已经处理了大部分相关工作,不过这个技能也提到了,如有需要可以集成原生代码。
详情
作者的原始描述
Build production React Native apps with Expo, navigation, native modules, offline sync, and cross-platform patterns. Use when developing mobile apps, implementing native integrations, or architecting React Native projects.
repo: wshobson/agents
热度
- GitHub 星标
- 41k
- 排名
- #6700
- 许可证
- MIT
- 更新时间
- 2026/10/15
评论
- …