Re:Making Sense of React Server Components
by keb_ on Wednesday September 06, 2023 @04:32PM
(#37410890)
> There is zero functionality that has been removed from class-based components.
No, but the React ecosystem has almost collectively migrated away from class-based components or deprecated support for them.
> Devs use hooks primarily because hooks are better.
You avoid much of the dependency array issues by using class components. But you have to deal with `this` and it's significantly more keystrokes. It's more of a tradeoff in my opinion.
Re:Making Sense of React Server Components
by paulddraper on Wednesday September 06, 2023 @09:16PM
(#37413587)
Well yes that's exactly what I said: it had been very very widely adopted
Re:Making Sense of React Server Components
by keb_ on Wednesday September 06, 2023 @11:55PM
(#37414576)
I don't see where you said that. It sounded to me like you were insinuating that hooks are inherently better than class components, and that zero functionality has been removed from class components, they are still viable (but they have largely been left in the dust by most popular libraries).
Also, devs don't use hooks primarily because they are better. They use them because they are idiomatic React in 2023.
Re:Making Sense of React Server Components
by paulddraper on Thursday September 07, 2023 @09:29AM
(#37418631)
That's akin to saying people don't like Taylor Swift's music because it is good, they like it because it is popular.
:hmm:
Re:Making Sense of React Server Components
by keb_ on Thursday September 07, 2023 @11:13AM
(#37420134)
It is not akin to saying that. Please argue in good faith [1]. Writing idiomatic React code makes a lot of practical sense (easier-to-find examples e.g. in the docs, wider library support, onboarding newbies). You can choose to use hooks while acknowledging the tradeoffs from class components.
Re:Making Sense of React Server Components
by uryga on Friday September 08, 2023 @12:53PM
(#37436133)
> zero functionality has been removed from class components
yes, exactly!
> They use them because they are idiomatic React
right, and do you think it'd be easy for a feature to become idiomatic if it wasn't an improvement over the previous patterns?
Devs use hooks primarily because hooks are better.