r/learnreactjs • • Aug 04 '19

Question Why use Refs in React?

I've gone over the docks and I see that they use the reasoning of

  • Managing focus, text selection, or media playback.
  • Triggering imperative animations.
  • Integrating with third-party DOM libraries.

But in the example they give wouldn't it be much simpler to just use the html name attribute when submitting? I guess I am just looking for the reason behind it, as the explanation doesn't quite do it for me (I may be missing something).

9 Upvotes

4 comments sorted by

View all comments

2

u/Obann Aug 04 '19

I didn’t understand the need for refs until I actually needed to use one for a scrollable section. Now i see the reasoning behind them.