Hacker News new | ask | show | jobs
by jschrf 436 days ago
The vast majority of state problems in React are a result of nonsense cargo culting around the idea that classes are somehow bad.
3 comments

I'm glad I learned React during the time when React.createClass was the only way. It was simple and intuitive. At that time the docs included a very lengthy discussion of what should be put inside the class and what should be passed via props. It was very helpful when it comes to teaching newcomers to architect their app. It also carried over the years of intuition by the typical dev working with OOP. Much better than the current trend of using hooks for everything.
I disagree. With classes, everything was stateful (because, y'know, classes). People were doing all sorts of crazy thing with the lifecycle methods and it was always a pain to have to remember the "this scope" and bind your event handlers. I saw so many bugs written by people who lost track of what "this" was.

Both paradigms have foot guns but having used both I much prefer the hook version.

IMO it's the central tenet to the dogma that "state must not be mutable".
The absolute nightmares people create in order to attain this ideal...