Traits are okay: React 'Mixins' which I mentioned in my parent post are basically traits but at the framework level, which allows them to be smart about composing/merging the use of framework functionality normally accessed by overriding superclass methods (eg. componentDidUpdate). Traits still have the composability issues I mentioned for React Mixins: how do you avoid collisions between the namespaces of different traits while still allowing some to compose others?
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.
mambodog|7 years ago
mst|7 years ago
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.
danabramov|7 years ago
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...