Re:Rich Harris joins Vercel to work on Svelte full time
by TranquilMarmot on Thursday November 11, 2021 @11:47PM
(#29196395)
If I hadn't been using React for many years before they introduced useEffect and various other hooks, they would have all been incredibly confusing. They still are really confusing when used in "clever" ways, especially with developers being allergic to writing comments. Even something as simple as `// this will do X when the component unmounts` make reading usages of useEffect 10x easier (vs. having to remember what happens when you return a function)
Sometimes I do miss the simplicity of componentDidMount... I guess you can always still write class-based components. Too bad they're not in vogue anymore! Feels like every library is hooks-based these days.
Re:Rich Harris joins Vercel to work on Svelte full time
by francislavoie on Thursday November 11, 2021 @11:57PM
(#29196426)
Totally agree re comments. They're necessary. Hooks do have huge advantages for composability and flexibility, and that can't be denied. But the API is just so arcane.
If my company wasn't a React shop, I'd probably be using Vue. I used Vue at my previous company and liked it a lot.
Headless libraries like `react-table` that use hooks are a revelation though. So nice to get pretty much all the behaviour you could ever need, without it making UI decisions for you. Difficult to use at first and wrap your head around, but hoo boy is it great to have the power to fully control the rendering!
Re:Rich Harris joins Vercel to work on Svelte full time
by phist_mcgee on Friday November 12, 2021 @06:02PM
(#29205516)
It's very easy to convert a hook to a HoC, purely wrapping that functionality in a class component.
Re:Rich Harris joins Vercel to work on Svelte full time
by TranquilMarmot on Saturday November 13, 2021 @12:17AM
(#29207598)
Also true. It just seems like `class` has become a bit of a dirty word, at least the last two places that I've worked on React codebases.
Re:Rich Harris joins Vercel to work on Svelte full time
by phist_mcgee on Sunday November 14, 2021 @03:47AM
(#29216122)
I agree it has. I think this is because hooks have been talked about by facebook as the future of react. There seems to be no appetite for class based react improvements in the future. No wonder people move to the thing that will be better supported, regardless what it is.
And don't even get me started about the dependencies array, which has different behaviour whether you omit the argument, or pass an empty array, or pass actual `useState` dependencies, or pass other unrelated variables. Again, it's something you just "need to memorize" to use React.