interface PropsType {
children: JSX.Element
name: string
}
class Component extends React.Component‹PropsType, {}› {
render() {
return (
‹h2›
{this.props.children}
‹/h2›
)
}
}
// OK
‹Component›
‹h1›Hello World‹/h1›
‹/Component›
// Error: children is of type JSX.Element not array of JSX.Element
‹Component›
‹h1›Hello World‹/h1›
‹h2›Hello World‹/h2›
‹/Component›
// Error: children is of type JSX.Element not array of JSX.Element or string.
‹Component›
‹h1›Hello‹/h1›
World
‹/Component›