I use React with Typescript and a functional approach.
const Divider: React.FunctionComponent<CardDividerProps> = (props: CardDividerProps) => (
<div>
divider
</div>
);
const Card: React.FunctionComponent<CardProps> = (props: CardProps) => (
<div>
card
</div>
);
Card.Divider = Divider; //Property 'Divider' does not exist on type 'FunctionComponent<CardProps>'.
If I remove the explicit type from the Card, it works. But I want to specify it with React.FunctionComponent... Is it possible?
I guess I can create a type:
type CardWithDividerComponent = {
(props: CardProps): JSX.Element;
defaultProps: CardProps;
Divider: React.FunctionComponent<CardDividerProps>;
}
But is this the only solution? Is there any solution with React.FunctionComponent
?