Hacker News new | ask | show | jobs
by mst 2691 days ago
Hence why I've been playing around with class decorators and friends to try and figure out a nice way to do method modifiers, traits, etc.

But I got sidetracked with "but howtf do I make typescript understand the resulting signatures" and then got nerd sniped by something else.

Hopefully eventually I'll get back to it.

1 comments

If you want to understand what Hooks are for, I wrote this piece:

https://medium.com/@dan_abramov/making-sense-of-react-hooks-...

I hope you find it helpful!

Hooks aren't _quite_ like traits or mixins or anything else. You can apply the same Hook multiple times and pass values between them. That's what makes them powerful.

Look at my last demo.

https://overreacted.io/making-setinterval-declarative-with-r...

Yeah, definitely a different beast. I've done things with what's basically dynamic scope trickery before now, though it didn't look exactly like hooks.

I still want traits because I've got very fond of doing class-with-read-only-members type stuff and being able to compose functionality together works really nicely in that regard

(nonetheless, I very much appreciate your efforts on elucidating hooks - I think most of the reason I'm replying this confidently is as combination of your articles and the reference docs :)