The Problem with Manual useEffect Data Fetching
What You'll Learn
You'll discover why writing your own data fetching logic inside useEffect creates a maintenance nightmare, even when you handle race conditions and cleanup correctly.
The Boilerplate Burden
By now, you've seen the full pattern: useEffect, AbortController, loading states, error handling, ignore flags, cleanup functions. Every time you need to fetch data, you're rewriting the same 30+ lines of code. You're essentially building your own mini data-fetching library from scratch, in every component.
Here's what you're managing manually every single time:
- Loading states (
isLoading,setIsLoading) - Error states (
error,setError) - Data states (
data,setData) - Race condition prevention (ignore flags or
AbortController) - Cleanup logic (aborting requests, preventing state updates after unmount)
- Dependency tracking (avoiding stale closures)
- StrictMode double-fetch handling
The Hidden Problems
Even with perfect implementation, manual useEffect fetching has critical gaps:
No caching: Fetch the same user profile in three components? That's three network requests, every single render cycle.
No deduplication: Two components request /api/users/1 simultaneously? Two requests sent.
No retry logic: Network hiccup? You're on your own.
No background refetching: Data goes stale, but you'd never know.
Hard to test: Mocking timings, race conditions, and cleanup in tests is painful.
The Real Cost
This isn't just about typing. It's about bugs lurking in every component and cognitive load every time you need simple data. Modern data-fetching libraries solve all of this automatically.
Key Takeaway: Manual useEffect data fetching forces you to rebuild the same complex infrastructure everywhere, without caching, deduplication, or retries—problems solved libraries like React Query and SWR handle automatically.