useImperativeHandle
customizes the instance value exposed to parent components, used with forwardRef
for controlled access to a child’s methods.
const CustomInput = forwardRef((props, ref) => {
useImperativeHandle(ref, () => ({
focus: () => inputRef.current.focus()
}));
return <input ref={inputRef} />;
});