Skip to main content

Nov 2026 · Guide · ~8 min read

Stop Fetching Data in useEffect

By Safdar Ali — frontend engineer, Bengaluru

I'm Safdar Ali. useEffect runs after the browser paints. A fetch inside it means the first paint is empty on purpose. You then write isLoading, a race when the id changes, and a cleanup flag so a slow response does not set state on an unmounted screen.

If the data is known when the page renders, fetch it on the server and pass it in. The HTML includes the content. There is no loading flag for the initial view. This is the default in the App Router.

An effect fetch is still reasonable for data that depends on the browser only: a measurement, a client-only subscription, something you cannot know at request time. Even then, cancel or ignore the stale response. The id in the dependency array is not optional.

A waterfall is two of these in a row: the page fetches a user, then a child effect fetches their projects. Both could have been one server render. I look for that pattern in review before I look at memo.

The useEffect mistakes post lists the other ways the hook goes wrong. Data loading is the one that hurts the first impression of the page.

If this helped you

I publish free tutorials and write-ups like this in my spare time — no paywall on the guides. If it saved you an afternoon of trial and error, you can support the work:

More guides on safdarali.in — same author, production-focused.

"Talk is cheap. Show me the code."