Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

It's not classes themselves, it's the lifecycle methods, the constructor, this, state, and it all interacts. Hooks let you do more or less the same thing, but IMHO with a simpler and clearer API.

You have more control too. Look at the parameters to useState to see what I mean.



I feel like there is an alternative world that we aren't seeing, where instead of changing the paradigm, the react team redesigned the class API instead.

The class API lifecycle methods are kind of a mess, and useEffect() seems like a more convenient abstraction. But I could imagine replacing the lifecycle methods with hooks that are added at object construction and get similar benefits. I wonder if the problem is not so much classes, but just the API that happened to evolve.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: