0
Challenge · 40Hooks & Effects

Strict Mode

Coreused in ~60% of apps

"Why does my console.log fire twice? Why does my fetch run twice?" — Strict Mode is doing it on purpose, in development, to expose bugs you'd otherwise ship. Once you understand it, the double-run stops being scary and becomes free QA.

Core idea. <StrictMode> is a development-only wrapper that intentionally double-invokes components, initializers, and effects (setup -> cleanup -> setup) to surface impure renders and missing effect cleanup. It does nothing in production.
Playground, this isn't a screenshot
Strict Mode
Effect
<Chat />
Strict Mode: dev double-invoke
open connections
none yet
press Mount
what runs on mount
Press Mount to play the mount sequence.

Strict Mode is development-only: it mounts, runs your effect, runs cleanup, then runs the effect again. In production the effect runs once. The double-invoke is a stress test — pure renders and paired cleanup make it a no-op; bugs make it loud.

↑ play a little first, then dig in