Hacker News new | ask | show | jobs
by EugeneOZ 3360 days ago
"extends" is often a bad idea. https://en.wikipedia.org/wiki/Composition_over_inheritance

It's sad to see how new generation can't learn lessons of the past.

1 comments

Yes and in fact it is right in our docs.

https://facebook.github.io/react/docs/composition-vs-inherit...

>So What About Inheritance?

>At Facebook, we use React in thousands of components, and we haven't found any use cases where we would recommend creating component inheritance hierarchies.

We dislike inheritance as much as you do, but we also dislike ad hoc class systems that have worse performance.

Example with "extends" is also in your docs (exactly by link of this post), so I'm not sure what it proves.
That's extending the base react component class, not an existing component class.
Well, if you think there's a difference then we never agree :)
Creating a nested class hierarchy and extending a single base class for all components are decidedly not the same thing.