DEV Community

Discussion on: Today I learned - React refs

Collapse
 
jivkojelev91 profile image
JivkoJelev91

Nice, i recommend you, don't use it.

Collapse
 
dance2die profile image
Sung M. Kim • Edited

It's literally an "escape hatch" as the React doc the @kethmars linked. (translates to, "don't abuse it" 😉)

One instance you can use is when you want to integrate JS library w/o React version.

Collapse
 
kethmars profile image
kethmars • Edited

Hey Jivko! Thanks for the comment.

Can you elaborate please :) ?

I guess that refs can easily be misused because you shouldn't need DOM access too much in libraries that work like React. But there are times when it makes sense. For example combination with event.target.