Reputation: 31605
I have a prop that I will use JSX on it, and I need to define it's type.
interface CustomComponentProps {
Component: // What should I put here?
}
const CustomComponent = ({ Component }: CustomComponentProps) => {
// some other stuff
return <Component someProp={foo} />
}
What is the type for a prop that can be used with jsx?
Upvotes: 0
Views: 73
Reputation: 13642
You can use React.ComponentType<T>
which accepts both React.FC
and React.Component
:
interface CustomComponentProps {
Component: React.ComponentType<{ someProp: string }>
}
Upvotes: 1