🌱 Typing a dynamic tag in React with TypeScript
interface CompProps {
tag: keyof JSX.IntrinsicElements
}
const MyComponent: React.FunctionComponent<CompProps & React.HTMLAttributes<HTMLOrSVGElement>> = ({
tag: Wrapper = 'div',
children,
...rest
}) => {
return <Wrapper {...rest}>{children}</Wrapper>
}