Refs with useRef
Hold values that survive renders without causing them, reach into DOM nodes when you must, and forward refs through your own components.
- Level
- Intermediate
- Chapters
- 4
- Exercises
- 1
- Reading time
- 15 min
What you will cover
- 1. What a Ref IsA box React keeps for you, and how it differs from state.
- 2. Reaching into the DOMAttaching a ref to an element, and the small number of jobs that justify it.
- 3. Forwarding RefsLetting a parent reach the DOM node inside your component.
- 4. Refs in PracticeTwo patterns worth keeping, and the mistakes to avoid.
Up next after this one: Context and Shared State