Answer
State participates in rendering: updating it schedules another render. A ref holds a mutable value across renders without causing a render when its current property changes.
Explanation
Use a ref for values that do not affect visible output, such as a timer ID or a DOM node. Avoid reading or writing refs during rendering except for safe initialization.
Example
const timeoutId = useRef<number | null>(null)