In JSX, content placed between a component’s opening and closing tags becomes its children prop. In <Greeting>Hello</Greeting>, the Greeting component receives "Hello" as props.children, enabling wrapper components and reusable composition. section 4.1
Function-as-children
Children can also be a function that receives data from its parent. DataProvider invokes children(data), allowing <DataProvider>{data => <p>{data}</p>}</DataProvider> to control how dynamic content is rendered.
Interview points to articulate:
- Explain that JSX transforms nested content into the children prop. section 4.1
- Distinguish ordinary nested content from function-as-children, which supports dynamic composition. section 4.1
Listing 4.1 A parent component provides dynamic data to its child
const DataProvider = ({
children,
}: {
children: (data: string) => React.ReactNode;
}) => {
const data = "Dynamic data from parent";
return <>{children(data)}</>; #A
};
<DataProvider>
{(data) => <p>{data}</p>}
</DataProvider>;
Inspect the TypeScript implementation of function-as-children and its parent-provided data flow. section 4.1



