Start here. This is the direct spoken answer to practice first.
Overview
The choice depends on whether a value participates in the rendered result, not merely whether it changes.
I use state when a change must be reflected in the UI, because updating state schedules a render. I use a ref for a value that must survive renders but does not determine the output, such as a DOM node, timer handle, previous request token, or latest callback reference. Changing ref.current does not rerender the component.