Stale Closure
Noun · Development
Definitions
A bug in JavaScript (especially React hooks) where a closure captures a variable by reference at a particular point in time and continues to use that now-outdated value in subsequent executions, rather than the current value. This commonly occurs when a useEffect or event handler closes over a state variable but lacks it in its dependency array.
In plain English: When a function remembers an old version of a value instead of the current one, causing it to work with outdated information.
Example: "The counter shows 0 every time because the setInterval callback has a stale closure over the initial count value — add count to the useEffect dependency array."