Skip to content
JavaScript·Advanced·Conceptual·1 min read

What is a stale closure in React?

Short interview answer

A callback created during a render sees the props and state from that render. If an effect or delayed callback continues using it after values change, it may observe an old snapshot. Correct dependencies, functional state updates, or a ref for deliberately mutable current data solve different versions of the problem.

Common follow-up questions

Does adding every value to an effect dependency list always solve it?

It keeps the effect synchronized, but may reveal that the effect owns the wrong responsibility. Sometimes the better fix is deriving during render, moving logic into the event, or using a functional update.

Key takeaway

Explain the underlying mental model clearly, then support it with a concrete example and its trade-offs.

← Back to Closures

Related questions