3 ms·
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
by awestroke 7y 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.
- batiste 7y agoWould it be possible to have a single method on a class that behaves like whatever useEffect is doing?
- lindskogen 7y agoNot in a single method, no. Watch this talk for more details! https://www.youtube.com/watch?v=wXLf18DsV-I https://www.youtube.com/watch?v=wXLf18DsV-I
- batiste 7y agoWell, I did something a bit similar my own language: https://github.com/batiste/blop-language/commit/90e7704e125ffb3c1fe6b4de2446680d3819ab7e https://github.com/batiste/blop-language/commit/90e7704e125f... Not sure where classes are an issue with doing anything like this
- TechBro8615 7y agoAdding 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.