1
2interface ParentCompProps {
3 childComp?: React.ReactNode;
4}
5
6const ChildComp: React.FC = () => <h2>This is a child component</h2>
7
8const ParentComp: React.FC<ParentCompProps> = (props) => {
9 const { childComp } = props;
10 return <div>{childComp}</div>;
11};
12
13function App() {
14 return (
15 <>
16 <ParentComp childComp={<ChildComp />} />
17 <ParentComp childComp={<h3>Child component 2</h3>} />
18 <ParentComp childComp={(
19 <div style={{border: '2px solid red'}}>
20 <h4>Child component</h4>
21 <p>With multiple children</p>
22 </div>
23 )} />
24 </>
25 );
26}
27
1type ViewProps = React.ComponentProps<typeof View>
2// or
3type InputProps = React.ComponentProps<'input'>