ReactBeginner#patterns

What is the children prop and composition?

children is whatever a component wraps, letting you build generic layout and wrapper components instead of coupling them to specific content.

Example
function Card({ title, children }) {
  return <div className="card"><h3>{title}</h3>{children}</div>;
}
<Card title="Stats"><Chart /></Card>

Related Questions

1
ReactBeginner#jsx

What are fragments and why use them?

Open
2
ReactBeginner#jsx

What is conditional rendering in React?

Open
3
ReactAdvanced#errors

What is an error boundary?

Open