一键导入
react-native-data-fetching-api
Guidelines for managing server state, queries, and API clients in React Native.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Guidelines for managing server state, queries, and API clients in React Native.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | React Native Data Fetching & API |
| description | Guidelines for managing server state, queries, and API clients in React Native. |
This app uses TanStack React Query coupled with a custom Axios API Client.
apiFetch)All network requests MUST use the internal apiFetch wrapper located in src/api/client.ts.
import { apiFetch } from '@/api/client';
// Example of a typical fetch call
const fetchUser = async (userId: string) => {
return apiFetch<UserResponse>(`/users/${userId}`, {
method: 'GET',
requiresAuth: true,
});
};
axios directly in your screens or hooks.apiFetch automatically handles Authorization Headers and Error wrapping.Use React Query for all server state management.
['users', userId].Always wrap useQuery and useMutation in custom hooks.
// ❌ BAD
const { data } = useQuery({ queryKey: ['users'], queryFn: fetchUsers });
// ✅ GOOD
export const useUsers = () => {
return useQuery({
queryKey: ['users'],
queryFn: fetchUsers,
});
};
apiFetch throws errors using the custom createApiError factory.useMutation, handle errors gracefully, typically by showing a toast or alert, but prefer doing it within the component's onError callback or via a global error boundary.[!IMPORTANT] Do not use
useEffect+useStateto fetch data. React Query is the standard.
Mandatory rules and components for handling keyboard avoidance smoothly in the React Native app.
How to correctly handle and format protobuf Timestamp dates sent by the API Gateway to prevent "Invalid Date" issues.
Senior-level React Native architecture and patterns for Expo 54 apps.
Strict coding standards, naming conventions, file size limits, and typing rules.
Best practices for implementing forms with React Hook Form and Zod.
Mandatory rule to never use deprecated APIs or ignore deprecation warnings.