DEV Community

Discussion on: Storing values with the useRef hook

Collapse
emma profile image
Emma Goto 🍙 Author

Hi! Good point on keeping their usages inside of useEffect.

Storing variables in useState will be fine most of the time, but if you're in a situation where you're concerned about unnecessary re-renders impacting performance, this can be a useful way of getting around that. A real use-case might be if you had some sort of isFetching or hasMounted boolean that you need to keep track of.