4 ms·
The fact that it’s unintuitive and different is why hooks are a joke. Class components just make sense.
by geraldwhen 4y ago
The fact that it’s unintuitive and different is why hooks are a joke. Class components just make sense.
- 1attice 4y agoTBH I disagree, I prefer strict functional programming, mostly for composability. Class components feel like translating everything into latin numerals and then back out again. Hooks help me avoid that pain. But is the API perfect? Nope.
- mpeg 4y agoThere are also frameworks like solidjs which have similar syntax to React but avoid the complexity of hooks with a simpler API and no hook rules. Classes are not the only solution
- 1attice 4y agoLately I've been investigating Svelte. It looks really good, but I think I'm going to stick with React/Nextjs simply because of the ecosystem and switching cost. Again, this isn't 'American Idol for frameworks'; I'm not picking React because I think it's the best, or even better. I'm picking React because of the habitat, and because that habitat is now, in a sense, my hometown.
- mpeg 4y agoYeah of course, you always have to do what is best for your company/clients and React is always a great choice (can't beat the ecosystem) It's the same reason why I non-ironically recommend Wordpress to a lot of people that have super limited budgets and want the moon. I do enjoy trying all the different new approaches to UI development though, especially as I'm not a frontend developer so most of the time I write frontend code I'm building either internal tools or personal projects, so I get to experiment a lot.
- zinckiwi 4y agoI never had a problem with the explicit lifecycle methods in class components, and the concept of a functional component effectively being the render method in isolation. To me there’s only one clear advantage to hooks and that’s sheer reduction in raw lines of code. Having said that, it’s a pretty huge advantage for something like redux.