React Native interview question · Most asked
How do you fetch data robustly on mobile networks?
Summary
Handle loading, empty, error and success states; use timeouts; retry only network errors, timeouts and 5xx with exponential backoff; cache responses and refetch in the background; and refetch when the app returns to the foreground or reconnects.
Longer Answer
TanStack Query provides caching, retries, deduplication and background refetching; in React Native, connect it to AppState (focus) and NetInfo (online status). Use AbortController to cancel stale requests (e.g. superseded searches).
Key Points
- Four UI states.
- Timeouts + selective retries with backoff.
- Cache + background refresh; AppState and NetInfo wiring.
Deep dive: Mobile Apps with React Native and Expo: Fetching Data
More most-asked React Native questions
- What is React Native, and how does it differ from a hybrid (WebView) app?
- Explain the React Native threading model.
- What is the React Native New Architecture?
- When would you use FlatList instead of ScrollView, and how do you make long lists fast?
- Where should you store data on the device, and what should never go in AsyncStorage?
- How would you make a React Native app work offline?
- How do you handle authentication tokens in a mobile app?
- A screen in your React Native app is slow. How do you investigate and fix it?