Use useRef() to get a hold of DOM elements created by the component.

There are two parts to retrieving a DOM element reference:

  1. useRef() returns a ref object that contains a current property which will eventually contain the reference.
  2. ref={_ref_variable_} is a prop binding that will set the current property of the ref object to the DOM element.


The example on the right uses useRef() to get a reference to the input element. However, it is missing the ref prop binding. Add the ref prop binding to make the example work as expected

Edit Tutorial