Hacker News new | ask | show | jobs
by awestroke 2245 days ago
No, you use componentDidMount etc, spreading out the logic that could go into a single hook into multiple lifecycle methods, spaghettied with other logic. Hooks are much cleaner.
2 comments

Adding to this, hooks make it much easier to pull related state management code out of the component. They help make state logic just as composable as UI logic.
Would it be possible to have a single method on a class that behaves like whatever useEffect is doing?
Not in a single method, no. Watch this talk for more details! https://www.youtube.com/watch?v=wXLf18DsV-I
Well, I did something a bit similar my own language: https://github.com/batiste/blop-language/commit/90e7704e125f... Not sure where classes are an issue with doing anything like this