3 ms·
> Edit: The other nice things about hooks is their composability (and this is in fact related to what I said above). With class components, a component can have
by imbnwa 5y ago
> Edit: The other nice things about hooks is their composability (and this is in fact related to what I said above). With class components, a component can have one state object, so it's hard to compose with other "mixin" type behaviors that need their own dedicated state. You ended up with weird patterns like higher order components (à la Redux withStore) that have basically ceased to exist with hooks (replaced by a useStore hook which can opaquely manage its own state under the hood).
This is more because the React team didn't care to figure out proper mixins beyond "Object.assign all the things"[0]
[0]http://raganwald.com/2016/07/20/prefer-composition-to-inheritance.html http://raganwald.com/2016/07/20/prefer-composition-to-inheri...