Lesson 20 of 80
In development, React deliberately calls some functions twice — not a bug, a stress test designed to surface the exact impurity bugs that would otherwise hide until production.
11 min read
Every option explains itself — why the right one is right, and why each wrong one is wrong. Miss one and it comes back later on a spaced-repetition schedule.
Question 1 of 2
A useEffect with no cleanup fires a fetch twice in development under StrictMode. What is StrictMode actually revealing?
Hints without spoilers, and a plain explanation of why a wrong answer was wrong — answered only from this lesson. Free account, no card.
Sign up freeWhat interviewers actually ask about this, and what a strong answer has to cover.
A strong answer covers
Likely follow-ups
<StrictMode> doesn't render anything itself — it opts a subtree into extra development-only checks, the most surprising of which is: component render functions, and some effects, get called twice in a row. This is intentional and only happens in development; production builds run everything once, normally.
<StrictMode>
<App />
</StrictMode>
The reasoning: React's whole model depends on render being a pure function of props and state (no side effects, safe to call more than once with the same inputs). If calling something twice produces a visible difference, that's proof it wasn't pure — exactly the kind of bug that could otherwise cause subtle problems under React's newer concurrent features, which really can render a component more than once before committing.
<StrictMode> intentionally double-invokes component bodies and effects — only in development.
AbortController) that cancels the first fetch when the effect re-runs, which is correct behavior you'd want anyway."Why does my useEffect run twice in development?" is one of the most-asked real questions from anyone who's actually built with modern React — the strong answer explains why React does this deliberately, not just "that's a known quirk, ignore it."