Reputation: 6140
I asked another question that involved inheritance among React components. One answer stated that inheritance is counter-indicated for React components. I can construct examples where inheritance could add clarity and reduce code. Is inheritance an anti-pattern for React components? Why or why not?
Upvotes: 0
Views: 360
Reputation: 4011
A common question from developers coming from an OOP background... Here is a link from the official docs that clearly explains why composition is preferred over inheritance:
https://reactjs.org/docs/composition-vs-inheritance.html
Upvotes: 2