3 ms·
It’s a better representation of what’s going on underneath but FWIW I agree with you, there are very few instances where I find hooks code that’s as readable as
by afavour 5y ago
It’s a better representation of what’s going on underneath but FWIW I agree with you, there are very few instances where I find hooks code that’s as readable as class-based code.
I know I’m not typical at all but hooks kind of marked the point where I lost interest in keeping up with the changes in React. I’m lucky that my job doesn’t require me to and I’ve had a great time exploring options like Vue and Svelte. Svelte in particular feels like it takes the opposite approach to hooks-based React: rather than force you to think about the way React is processing things it lets you write code the way you think about things and transpiles it into working JS.
Beyond “everyone uses it” I can find few reasons to prefer React these days.
- stack_framer 5y agoThis is exactly how I feel. I remember watching the hooks announcement video and being surprised that classes, 'this', and the lifecycle methods were considered so ... problematic. It seemed like hooks were solving problems that, for me at least, were totally and completely non-existent. It didn't help that my first foray into hooks was trying to build a simple clock with `setInterval`: https://overreacted.io/making-setinterval-declarative-with-react-hooks/ https://overreacted.io/making-setinterval-declarative-with-r... I really need to give Svelte a try.
- sibeliuss 5y agoWhen React introduced hooks they also massively expanded the library's API, so there's a complexity cost to that. While I love working with hooks and do so daily, I definitely felt some remorse for those now having to figure out when and how to use memoization, dependency arrays, useCallback, etc, etc etc. React in its first formulation was utterly simple and beautiful. In defense of hooks however, it's good to keep in mind that now you can do a lot more than you could, and being able to share business logic so easily across an application is an elegant abstraction.