native-data-fetching
Installation
SKILL.md
Data Fetching in React Native
Overview
React Native uses the standard Fetch API but requires additional patterns for production apps: caching, mutation handling, authentication, offline support, and request cancellation. TanStack Query (React Query) is the standard solution for managing server state.
Core principle: Separate server state (fetched data) from client state (UI state). Use React Query for server state and React state/context for client state.
When to Use
- Making HTTP requests to REST or GraphQL APIs
- Caching API responses to avoid redundant network calls
- Handling optimistic updates and mutations
- Managing authentication tokens securely
- Supporting offline-first or intermittent connectivity
- Cancelling requests on component unmount or navigation