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

Imperative API with useImperativeHandle

useImperativeHandle attaches a custom object with focus and shake methods to the ref, exposing a clean API and hiding the input DOM details.

Loading live editor…