News for hackers. Stuff that matters.
Re:React I love you, but you're bringing me down by esprehn on Tuesday September 20, 2022 @01:09PM (#32914715)
That didn't require the meta language and rules of hooks though, they could have added this.addEffect(callback, deps) or something to class components. To preserve back compat they could have added a new base class you inherit from to get access to new APIs.

Most of hooks could have been done incrementally on top of classes.

Re:React I love you, but you're bringing me down by phailhaus on Tuesday September 20, 2022 @01:42PM (#32915150)
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.

Re:React I love you, but you're bringing me down by esprehn on Tuesday September 20, 2022 @09:33PM (#32919960)
Only 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