I would like to express the type of a component that takes certain props:
Just as an example, I would like to render anything that accepts an ISIN and a rate:
type Props = {
Item: TheQuestion;
data: {ISIN: string, ...};
}
function Renderer({Item, data}: Props) {
return <foo>
<bar />
<Item ISIN={data.ISIN} rate={80/64} />
</foo>;
}
How could I write the type I called TheQuestion here?
One thing that kind of works is React.FunctionComponent<{ISIN: string, rate: number}>,
but this only allows function components, not class-based ones.
Is there a generic type that accommodates both?