Home > shorts > Composition VS Inheritance in React

Composition VS Inheritance in React


React has a powerful composition model, and it's recommended using composition instead of inheritance to reuse code between components.

// Inheritance passed by name
<CrudButton children="Delete" />

// Composition passed by position
<CrudButton>
    <Symbol />
    Update
</CrudButton>

Check the demo here => CodePen

© 2021, Andrew Losseff