DEV Community

loading...

Discussion on: Everything you need to know about React Hooks

Collapse
szymkab profile image
Szymon Kabelis

To be honest you can extract reusable state logic by using abstract classes for example but rather for some small logic and I wouldn't go too far with that because it can quickly end up with ugly non-readable composition.

Also, I hate classes because you can quickly end up with a mess (lots of unrelated things in componentDidMount, componentWillUnmount, having the same state in multiple classes etc). Hooks are a really great improvement (for readability and composition).

Thread Thread
vcarl profile image
Carl Vitullo Author

Inheriting from a custom class is considered an antipattern in React, so while it works on a technical level I wouldn't say it's a viable option. All the downsides of mixins without any benefits over other ways of composing functionality.