Refs visual mental model
Refs persist between renders, but changing them does not request another render.
.current can change imperatively without scheduling React rendering.
State vs ref
Persists between renders. Setter schedules future rendering. Use it when JSX depends on the value.
Persists between renders. .current mutates immediately. Use it when React does not need to render the value.
DOM refs
renders an element with ref
input · dialog · canvas · video · measured element
focus · scroll · measure · play · integrate third-party widget
Why refs are escape hatches
Keep a narrow imperative handle React does not need for rendering.
Store UI/domain state in .current just to avoid re-renders.
If the interface depends on a value, hiding that value in a ref breaks React's normal reactive data flow.
Imperative handles
needs one imperative capability
focus() · open() · reset() — only what is intentionally exposed
stays encapsulated inside the child
Continue with useRef and DOM Refs and Imperative Handles for complete examples and edge cases.