用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/ffsshhttiikk/opencode-agents-skills --skill react-native命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
正在显示 SKILL.md
基于 SOC 职业分类
| name | react-native |
| description | Cross-platform mobile framework using React and JavaScript |
| tags | ["react-native","javascript","typescript","react","mobile","cross-platform"] |
I provide guidance for building cross-platform mobile applications using React Native. I cover JavaScript and TypeScript development, React Native CLI and Expo, component-based UI development, native module integration, and deployment to iOS and Android platforms.
Use me when building cross-platform mobile apps with a single JavaScript codebase, leveraging React expertise for mobile development, integrating with existing web codebases, or developing apps that need both iOS and Android support with shared business logic.
React Native component hierarchy and rendering to native views. JSX syntax for component definition. Props and state management with useState, useReducer, and Context API. React Native navigation with React Navigation (stack, tab, and drawer navigators). Native module integration for platform-specific functionality. FlatList and SectionList for efficient list rendering. StyleSheet for component styling with Flexbox layout.
React Native component with hooks:
import React, { useState, useEffect, useCallback } from 'react';
import {
View,
Text,
TouchableOpacity,
FlatList,
StyleSheet,
ActivityIndicator,
} from 'react-native';
interface User {
id: string;
name: string;
email: string;
}
const UserList: React.FC = () => {
const [users, setUsers] = useState<User[]>([]);
const [loading, setLoading] = useState(true);
const [page, setPage] = useState(1);
const fetchUsers = useCallback(async () => {
try {
const response = await fetch(
`https://api.example.com/users?page=${page}`
);
const data = await response.json();
setUsers(prev => [...prev, ...data.users]);
} catch (error) {
console.error('Failed to fetch users:', error);
} finally {
setLoading(false);
}
}, [page]);
useEffect(() => {
fetchUsers();
}, [fetchUsers]);
const renderItem = ({ item }: { item: User }) => (
<TouchableOpacity style={styles.card}>
<Text style={styles.name}>{item.name}</Text>
<Text style={styles.email}>{item.email}</Text>
</TouchableOpacity>
);
const loadMore = () => {
setPage(p => p + 1);
setLoading(true);
};
return (
<FlatList
data={users}
renderItem={renderItem}
keyExtractor={item => item.id}
onEndReached={loadMore}
onEndReachedThreshold={0.5}
ListFooterComponent={
loading ? <ActivityIndicator size="large" /> : null
}
contentContainerStyle={styles.container}
/>
);
};
const styles = StyleSheet.create({
container: { padding: 16 },
card: {
backgroundColor: '#fff',
padding: 16,
marginBottom: 12,
borderRadius: 8,
elevation: 2,
shadowColor: '#000',
shadowOffset: { width: 0, height: 2 },
shadowOpacity: 0.1,
},
name: { fontSize: 16, fontWeight: '600' },
email: { fontSize: 14, color: '#666', marginTop: 4 },
});
export default UserList;
Custom hook for data fetching:
import { useState, useEffect, useCallback } from 'react';
interface UseFetchResult<T> {
data: T | null;
loading: boolean;
error: Error | null;
refetch: () => void;
}
function useFetch<T>(url: string): UseFetchResult<T> {
const [data, setData] = useState<T | null>(null);
const [loading, setLoading] = useState(true);
const [error, setError] = useState<Error | null>(null);
const fetchData = useCallback(async () => {
try {
setLoading(true);
const response = await fetch(url);
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
const result = await response.json();
setData(result);
} catch (err) {
(err ? err : ());
} {
();
}
}, [url]);
( {
();
}, [fetchData]);
{ data, loading, error, : fetchData };
}
useFetch;
Choose Expo for rapid development or React Native CLI for bare workflow with native code needs. Use TypeScript for type safety and better IDE support. Separate concerns with custom hooks for reusable logic. Optimize list performance with FlatList virtualization and proper key usage. Implement proper error boundaries for graceful error handling. Use React Navigation for declarative navigation patterns. Test components with React Native Testing Library.
Custom hooks for extracting and reusing component logic. Context API for global state like themes and authentication. Render props pattern for flexible component APIs. Higher-order components for cross-cutting concerns (though hooks are preferred). Container/Presentational pattern separating UI from business logic. Compound components pattern for related components (like Accordion or Tabs).