Open kylpo opened 6 months ago
Does this work!? https://www.christianvm.dev/blog/react-as-prop
type PolymorphicProps<E extends React.ElementType> = React.PropsWithChildren< React.ComponentPropsWithoutRef<E> & { as?: E } > type TypographyProps<T extends React.ElementType> = PolymorphicProps<T> & { color?: string } export function Typography<T extends React.ElementType = 'p'>({ as, color, ...props }: TypographyProps<T>) { const Component = as || 'p' console.log(color) return <Component {...props} /> }
Does this work!? https://www.christianvm.dev/blog/react-as-prop