← React Beginner Questions - Set 5 Q49
React Beginner Questions - Set 5
`children` is the composition primitive: it lets a component wrap arbitrary content without knowing what it is.
function Panel({ title, actions, children }) {
return (
<section className="panel">
<header>
<h2>{title}</h2>
{actions}
</header>
<div className="panel__body">{children}</div>
</section>
);
}
function App() {
return (
<Panel title="Orders" actions={<button>Reload</button>}>
<p>Anything here arrives as `children`.</p>
<ul><li>#1001</li><li>#1002</li></ul>
</Panel>
);
}