The short answer is that you can use useRef when you want to persist some value in multiple renders of your component (similar to useState) but you don't want to re-render that component when that value changes.
Tyler McGinnis has one of the best explanation on how to use useRef
The short answer is that you can use
useRef
when you want to persist some value in multiple renders of your component (similar touseState
) but you don't want to re-render that component when that value changes.Tyler McGinnis has one of the best explanation on how to use useRef
Thank you so much! That link you've shared is very useful.