Whatever you put between a component's tags arrives as the children prop. Build a Card that can wrap any content.
React · beginner · 5 min · 5 steps · free
function Card({ title, children }) {
return (
<section className="card">
<h3>{title}</h3>
{children}
</section>
);
}
export default function App() {
return (
<Card title="Shopping list">
<ul>
<li>Milk</li>
<li>Bread</li>
</ul>
</Card>
);
}<App> for the first time: it calls the App function.App puts a list between <Card> and </Card>. That content is passed to Card as a prop named children.Card with title and children.{children} places the list inside the section, under the heading. The State panel shows children as the <ul> JSX.Answer: <p>Hi</p>. The content between the tags.
Answer: Not shown. React only shows what the component returns.
← Components and Props · Conditional Rendering →