Lesson

Refs in React

A ref is short for reference. A ref is used for referencing a DOM element and interacting with that DOM node directly.

Duration
4 min
Access
Free
Transcript
Available

A ref is short for reference. A ref is used for referencing a DOM element and interacting with that DOM node directly.

Though this is a step away from React's approach of rendering through props, React's docs specify a few good use cases for Refs:

  1. Managing focus, text selection, or media playback.

  2. Triggering imperative animations.

  3. Integrating with third-party DOM libraries.

Link to the repo: https://github.com/AkashGutha/egghead-singles/tree/master/20-create-refs