Skip to content
React·Intermediate·Coding·1 min read

What's a concrete sign that a component needs a composition pattern instead of more props?

Short interview answer

A prop list growing with variations like renderHeader, renderFooter, showIconA, showIconB for every new visual variant — each addition requires touching the shared component itself instead of composing existing pieces differently.

Example

JSX
// Smell: every variant adds a prop to the shared component<Card renderHeader={...} renderFooter={...} showBadge dense />
// Composition: the caller assembles the parts it needs<Card><Card.Header>...</Card.Header><Card.Body>...</Card.Body></Card>

Key takeaway

Explain the underlying mental model clearly, then support it with a concrete example and its trade-offs.

← Back to Component composition patterns

Related questions