Composition vs Inheritance

React has a powerful composition model, and we recommend using composition instead of inheritance to reuse code between components.

Welcome

Thank you for visiting our spacecraft!



Specialization

In React, this is also achieved by composition, where a more “specific” component renders a more “generic” one and configures it with props:

Welcome

Thank you for visiting our spacecraft!


Composition works equally well for components defined as classes:

Mars Exploration Program

How should we refer to you?


So What About Inheritance?