Official ReactJs documentation recommends to create components following the dot notation like the React-bootstrap library:
<Card>
<Card.Body>
<Card.Title>Card Title</Card.Title>
<Card.Text>
Some quick example text to build on the card title and make up the bulk of
the card's content.
</Card.Text>
</Card.Body>
</Card>
Thanks to this question, I know that I can create this structure using functional components just like that in javascript:
const Card = ({ children }) => <>{children}</>
const Body = () => <>Body</>
Card.Body = Body
export default Card
Using TypeScript I decided to add the corresponding types to it:
const Card: React.FunctionComponent = ({ children }): JSX.Element => <>{children}</>
const Body: React.FunctionComponent = (): JSX.Element => <>Body</>
Card.Body = Body // <- Error: Property 'Body' does not exist on type 'FunctionComponent<{}>'
export default Card
Problem is now that TypeScript don't allow the assignment Card.Body = Body
and give me the error:
Property 'Body' does not exist on type 'FunctionComponent<{}>'
So how can I type this correctly in order to use this code structure?