React devs, you see this in every beginner tutorial:
useEffect(() => {
fetchUsers();
});
…and you think yeah, that’s how you fetch data.
But In production nobody fetches like this. Not even close.
Production code has few options:
1) TanStack Query (the undisputed king in 2026)
It’s not just fetching
it’s a full data synchronization engine:
- Automatic caching deduplication (no duplicate calls)
- Background refetching, stale-while-revalidate, polling
- Built-in loading, error, and success states
- Infinite queries pagination out of the box
- Mutations with optimistic updates & rollback
- Devtools that show you exactly what’s happening
- Request cancellation built-in
You just write `useQuery` and move on. Clean. Powerful. Battle-tested.
2) Or your team’s custom data layer (the 'we built it ourselves' route)
A heavily opinionated helper function/custom hook that does all the heavy lifting so your components stay very simple:
- Axios instance with interceptors for:
- Dynamic headers (Content-Type, Accept, custom tracking)
- Auth (JWT/Bearer automatic token refresh on 401) - BaseURL switching per environment
- AbortController logic in every request (cleanup on unmount so then no memory leaks or race conditions)
- Retry logic with exponential backoff
- Global error handler -->> toast notifications or error boundaries
- Infinite scroll / pagination logic (IntersectionObserver cursor-based or offset)
- Request deduping loading state management (spinner or skeleton)
- Type safety runtime validation (Zod)
- Analytics tracking on every API call (if needed)
- Timeout rate-limit protection
The component? Looks like:
const { data, isLoading } = useUsers();
That is it. Everything else is abstracted away.
Tutorials show the toy version, most times.
Production ships the system.
So next time you see a raw `fetch` inside `useEffect` with no dependency array… you already know what the PR comment will be
What is YOUR production data-fetching setup?
You see this in a React component:
useEffect(() => {
fetchUsers();
});
What are your PR comments ?