DEV Community

Discussion on: React Refs: The Complete Story

Collapse
 
crutchcorn profile image
Corbin Crutchley

Should a developer really rely on this?

Absolutely! Keep in mind, using refs isn't simply some philosophical rationale of "correctness", they prevent renders. This means that if you're, say, using a timer to keep track of a setTimeout to clear later (like in one of these examples), you don't want to trigger a re-render.

Not only can a re-render during that change cause performance issues, but also introduce behavioral issues as well.

While this article is long to create a more cohesive story, if you wanted a TL;DR it'd be something along the lines of:

"useRef for data causes no-rerenders. Use it wisely"