I'm trying to implement a custom label component with Typescript, building on the <Label /> component that comes with theme-ui. My first attempt looks something like this:
export const CustomLabel = React.forwardRef<HTMLLabelElement, LabelProps>(
(props , ref) => <Label ref={ref} {...props} />
);
I would've expected this to work, but instead I get the following error on ref={ref}:
Type 'string | ((instance: HTMLLabelElement | null) => void) | RefObject<HTMLLabelElement> | null' is not assignable to type '((instance: HTMLLabelElement | null) => void) | RefObject<HTMLLabelElement> | null | undefined'.
Type 'string' is not assignable to type '((instance: HTMLLabelElement | null) => void) | RefObject<HTMLLabelElement> | null | undefined'.
Am I doing something very silly here? Has anyone else run into a similar issue?