useImperativeHandle

Rarely used, useImperativeHandle() lets you customize which properties get exposed on a ref, and what additional customizations to make in the exposed methods. It takes the ref as its first argument — traditionally obtained via forwardRef(), though React 19 also lets a function component receive ref directly as a normal prop without forwardRef. It may accept a dependency array as the third argument, just like useEffect and useMemo.