Laizer
Laizer

Reputation: 6140

Is inheritance in React components an anti-pattern?

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

Answers (1)

SakoBu
SakoBu

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

Related Questions