Nov 2026 · Guide · ~8 min read
useEffect Mistakes I Still See in React Code Review
By Safdar Ali — frontend engineer, Bengaluru
I'm Safdar Ali. useEffect is for synchronising with a system outside React: a subscription, a timer, a browser API. It is not "componentDidMount for everything I forgot earlier."
Fetching in an effect is the mistake I comment on most. The user sees an empty screen, then the data. On a Next.js page the fetch belongs on the server. I wrote that up on its own because it keeps coming back.
A missing dependency is a stale closure. The effect captured old props and will not see the new ones. Adding the dependency is the fix. If that makes the effect re-run too often, the effect is doing too much, not the array.
An empty dependency array with a lint disable is a decision to freeze the first render. Say so in a comment if you mean it. Do not use it to silence a warning you did not understand.
Code that runs because someone clicked belongs in the click handler. Putting it in an effect that watches a "clicked" flag is an extra render and an extra bug. Effects react to rendered output. Events are the user.
Clean up subscriptions and timers. The function the effect returns exists so Strict Mode and a fast navigation do not leave two listeners. If you cannot describe the cleanup, you probably did not need the effect.
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:
- Buy me a coffee at buymeacoffee.com/safdarali
- Subscribe to my YouTube channel — it's free; 70+ React & Next.js tutorials
Related reading
More guides on safdarali.in — same author, production-focused.
- Guide
How to Build a Frontend Developer Portfolio That Stands Out
Frontend developer portfolio guide for India — sections, React/Next.js examples, SEO, performance, personal branding, FAQ, and checklist to build and rank.
May 2026Read article →
- Guide
React Server Components vs Client Components — When to Use Which
Practical RSC vs client guide for Next.js App Router — when to use each, real code, bundle before/after, and performance impact.
May 2026Read article →