What is React component composition vs inheritance?
Updated Apr 23, 2026
Short answer
In React, composition means building components by combining smaller components together, while inheritance means trying to reuse component behavior by extending one component from another.
React strongly prefers composition over inheritance because it is more flexible, simpler, and aligns better with how UI is designed.
Deep explanation
1. What is Composition?
Composition means you build complex UIs by nesting components inside other components.
Instead of trying to reuse behavior through class hierarchies, you reuse code by passing components, props, or children.
React uses composition in multiple ways:
- Props-based composition
```jsx function Button({ label }) { return <button>{label}</button>; }
function App() { return <Button label="Click Me" />; } ```
- Children composition
```jsx function Card({ children }) { return <div className="card">{children}</div>; }…
Unlock with a Pro subscription to view this section.
View pricingReal-world example
No real-world example available yet.
Unlock with a Pro subscription to view this section.
Upgrade to ProCommon mistakes
No common mistakes listed yet.
Unlock with a Pro subscription to view this section.
Upgrade to ProFollow-up questions
No follow-up questions available yet.
Unlock with a Pro subscription to view this section.
Upgrade to Pro