8 ms·
Imagine trying to debug a component that both has lifecycle methods and reactive hooks? That would be a total nightmare, especially when the same state is being
by phailhaus 4y ago
Imagine trying to debug a component that both has lifecycle methods and reactive hooks? That would be a total nightmare, especially when the same state is being updated in both places (because that would have to be allowed). Going all-in on hooks means that there are two distinct, independent ways of writing components, and you never have to deal with interactions between the two.
I also don't think this would be possible. Hooks are based on closures and injected state, which you can't do in a class since separate methods won't share the closure.
- esprehn 4y agoOnly if you're constrained by the existing API of hooks. Preact signals is a good example of how class components could have been improved with reactivity: https://twitter.com/_developit/status/1567272951136788481 https://twitter.com/_developit/status/1567272951136788481