Design Patterns · Junior · Question 34 of 75

What does "composition over inheritance" mean?

Explanation

Deep inheritance is fragile: a change in the base class breaks subclasses, and behavior gets "locked" into the hierarchy. Composition (functions, hooks, children, strategy objects) is more flexible. React explicitly recommends composition over component inheritance.

Further reading

Problem with a question

Design Patterns · Junior · question 34

Test yourself

Take the Design Patterns · Junior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz