4 ms·
I agree, and I'd like an anti-hooks person to explain their thoughts a bit more. My impression is that they believe useEffect inclines devs to cause side-effect
by wildrhythms 4y ago
I agree, and I'd like an anti-hooks person to explain their thoughts a bit more. My impression is that they believe useEffect inclines devs to cause side-effects in the component, quickly making the logic of a component difficult to follow- for example, a useEffect that sets a state that kicks off another useEffect that sets another state that kicks off another useEffect...
But this problem existed before hooks: old school React devs will remember the days of class-based components with humongous componentDidUpdate methods peppered with calls to this.setState(...) that did the same thing.
My own impression is that hooks offer better lifecycle controls overall, with the side effect (heh..) of handing devs an arsenal of footguns that will inevitably go off if they don't fully understand the hooks or where to use them or how React detects and triggers a re-render. So in a way I agree with the author of the original article here, but in the sense that React devs should probably not use hooks until they understand how re-renders happen and why to avoid that and only then should they be handed one footgun at a time.
- rk06 4y agoMy problem with hooks isn't the philosophy but the ergonomics and footguns it creates. Compare that with Vue composition api, and you can see how idea of hooks can be implemented much better[0] [0] https://vuejs.org/guide/extras/composition-api-faq.html#comparison-with-react-hooks https://vuejs.org/guide/extras/composition-api-faq.html#comp...