Glossary term
What is stale closure? Meaning for developers
In Senior Frontend Depth
A function that keeps seeing old values, because it captured them in an earlier render. Missing effect dependencies often cause it.
Learn it properly · Senior Frontend DepthLesson 1: Hooks in Depth: Effects, Refs and the RulesEffect dependencies, stale closures, useRef vs state, useLayoutEffect and the idea behind “You Might Not Need an Effect”.In React in Depth
A function that remembers an old value of a variable from the render where it was created.
Learn it properly · React in DepthLesson 2: Effects and the Lifecycle: useEffect Without the ConfusionWhat an effect is, dependencies, cleanup, why effects run twice in development, and when you do not need an effect.