useEffect looks simple. Add a function, add a dependency array, done.
Then production hits you with:
a timer that logs the wrong count
a fetch that sends a stale token
an effect that runs forever
or React Strict Mode making everything run twice
These are not random React bugs. They all come from one idea:
Every render is a snapshot. Your effect remembers the values from the render that scheduled it.
Once you internalize that sentence, most useEffect pain disappears.
🧠 The Core Mental Model
When React renders your component, it creates a snapshot of props and state for that moment.
function Counter () { const [ count , setCount ] = useState ( 0 );
useEffect (() => { const id = setInterval (() => { console .…