jargon

Frontend & browser·JavaScript in the browser

the interval you set up on mount kept logging the count as zero no matter how many times you clicked.

Stale closure

Also calledcaptured stale value

A callback created in an earlier render still holding that render's variables while newer ones exist. It is the defining bug of hook-based components: an effect or subscription registered once captures the first render's state and never sees an update. The fixes are a dependency array that actually lists what the callback reads, a ref for values that must be current, or a state updater function instead of reading the value at all.

Commonly confused with