stale closure

A function that still sees old values because it was created during an earlier render and never replaced.

In more detail

An Effect or listener with an empty dependency array keeps the props and state of its first render forever. Include the values in the dependency array, use an updater function, or read the latest handler from a ref.

Related terms

Taught in

References