Interview · Tooling
StrictMode
Why do my effects run twice?
StrictMode activates extra behaviors only in development to catch subtle bugs: it mounts and unmounts components twice to verify effects have cleanup, and warns about deprecated APIs.
The double mount
In development, React mounts the component, unmounts it, and mounts it again. This simulates what happens with fast refresh and real remount scenarios. If your useEffect breaks when run twice, it means the cleanup function is missing.
Development only
The double mount doesn't happen in production. Its only purpose is to surface effects without cleanup before they reach users. The right signal isn't "why does this run twice?" but "does my effect work correctly if it runs twice?".
Common pitfalls
- 01If the double mount breaks your effect, don't remove StrictMode — it's a signal the effect needs a cleanup return.
- 02StrictMode doesn't affect production components — it's only a development tool to catch bugs early.
- 03In React 18+, the double mount also verifies components support unmount/remount without losing data — useful for the future Offscreen API.
Was this helpful?
Sign in to give feedback
