How does useImperativeHandle work with forwardRef?

useImperativeHandle must be used in conjunction with React.forwardRef because refs are not automatically passed down to child components. forwardRef allows the parent to pass a ref to the child, and useImperativeHandle customizes what the ref exposes.