useImperativeHandle

The useImperativeHandle hook customizes the instance value that is exposed when using ref.

Snippet:

useImperativeHandle(ref, () => ({ someFunction }));

Example:

useImperativeHandle(inputRef, () => ({ focus: () => inputRef.current.focus() }));