用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/G1Joshi/Agent-Skills --skill react-native命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
基于 SOC 职业分类
正在显示 SKILL.md
| name | react-native |
| description | React Native cross-platform mobile with JavaScript. Use for iOS/Android. |
React Native allows you to build native mobile apps using React and JavaScript/TypeScript. It renders veritable native UI components (not webviews), offering performance close to native apps while maintaining the React developer experience.
Using Expo (Recommended for 2024/2025):
npx create-expo-app@latest my-app
cd my-app
npx expo start
// app/index.tsx (Expo Router)
import { useState } from "react";
import { View, Text, Button, StyleSheet } from "react-native";
import { Link } from "expo-router";
export default function Home() {
const [count, setCount] = useState(0);
return (
<View style={styles.container}>
<Text style={styles.text}>Count: {count}</Text>
<Button title="Increment" onPress={() => setCount((c) => c + 1)} />
<Link href="/details" style={styles.link}>
Go to Details
</Link>
</View>
);
}
const styles = StyleSheet.create({
container: { flex: 1, justifyContent: "center", alignItems: "center" },
text: { fontSize: 24, marginBottom: 20 },
link: { marginTop: 20, color: "blue" },
});
React Native works by bridging JavaScript to Native UI components.
<View> maps to UIView (iOS) / android.view.View (Android).<Text> maps to UITextView / TextView.Layouts use Flexbox (like CSS), but defaults to flexDirection: 'column' (unlike row on web). Everything needs strict dimensions or flex grow capabilities.
React Native preserves local state while reloading components instantly on file save, significantly speeding up the dev loop.
Modern React Native apps use expo-router which mimics Next.js.
app/index.tsx -> Home screenapp/(tabs)/_layout.tsx -> Tab navigationapp/[id].tsx -> Dynamic routesAvoid Redux for API state. Use TanStack Query (React Query).
For global app state (theme, auth token), Zustand is preferred over Redux/Context for its simplicity and performance (selectors).
Do:
FlatList for long lists performance.Don't:
console.log in production builds (it slows down the bridge).| Error | Cause | Solution |
|---|---|---|
Metro Bundler process exited with code 1 | Port in use or bad cache. | npx expo start -c (clear cache). |
Invariant Violation: View config not found | Import issues or upgrading RN versions. | Check node_modules, clear watchman. |
CocoaPods could not find compatible versions | iOS dependency conflict. | cd ios && pod install --repo-update. |
Text strings must be rendered within a <Text> component | Raw text directly inside View. | Wrap all strings in <Text>. |