Course contentsShow
← React
Lesson 1147 of 2,39629. Composition: SlotsFree lesson

When Children is Enough

Learn when the simple children prop suffices: single content insertion, no complex logic, and when the parent doesn't need to interact with the content.

When Children is Enough

You'll learn: How to recognize when the simple children prop is all you need instead of complex slot patterns.

The Simplicity Test

After exploring slots, named props, and compound components, it's easy to over-engineer. But often, the built-in children prop is perfectly sufficient. The question is: when?

Use children when:

  1. You have one content area - There's a single placeholder where content goes
  2. No complex logic needed - You're not transforming, filtering, or manipulating what's passed in
  3. Parent doesn't interact with content - You just render it as-is, maybe wrapped in some structure
  4. Simple containment - The component is primarily a wrapper (layout, styling, behavior)

The Mental Model

Think of children like a picture frame. The frame doesn't care what picture you put in it—it just displays it. You don't need multiple "slots" for different picture parts. One opening is enough.

// Children is enough here:
function Card({ children }) {
  return <div className="card">{children}</div>;
}

// Use it:
<Card>
  <h2>Title</h2>
  <p>Content goes here</p>
</Card>

The Card doesn't need to know about titles vs content. It just wraps whatever you give it. No need for title and content props.

When to Graduate Beyond Children

If you find yourself wanting "header goes here, footer goes there," or needing to style different sections differently, then consider slots or compound components. But start simple.

Key Takeaway: If your component has one logical content area and doesn't manipulate what's inside, stick with children—it's React's most intuitive composition pattern.