See the ForwardRefRenderFunction.
interface Props {
children?: ReactNode;
type: "submit" | "button";
}
export const FancyButton = forwardRef<HTMLButtonElement, Props>((props, ref) => (
<button ref={ref} className="MyClassName" type={props.type}>
{props.children}
</button>
));
Lets your component expose a DOM node to a parent component using a ref.