Chapter 9 · Example 5 · Refs: from storing data to imperative API

Focusing a DOM element via ref

Attaching a ref to an input lets the form call ref.current.focus() on submit to focus the empty field, accessing the real DOM element directly.

Loading live editor…