News for hackers. Stuff that matters.
Re:If Not React, Then What? by crvst on Saturday November 30, 2024 @03:27PM (#42283810)
That’s true. Just to note, I never claimed otherwise. See, useEffect is an evil remark. This is more based on my experience working with an average React codebase.

As for your question, “Why does everyone suddenly try to use it for spreading butter or peeling eggs?”

I guess part of the reason is that many people rely on older tutorials and patterns where the usage of useEffect was much more tolerated or even encouraged as a catch-all solution. There’s still a lot of inertia from the old componentDidThis/componentDidThat paradigm, with useEffect being its direct replacement.

I feel it is only a recent tendency to finally abandon the overuse of effect hooks.

Just open an average Stack Overflow React question, and you’ll see how many useEffects are crammed in there.

Re:If Not React, Then What? by boredtofears on Saturday November 30, 2024 @07:05PM (#42285014)
How do you fetch and persist server side data without useEffect? (Assuming vanilla react)
Re:If Not React, Then What? by crvst on Sunday December 01, 2024 @01:01AM (#42286545)
That’s probably the main real-world use case for useEffect. Dedicated third-party libraries like React Query obviously use useEffect under the hood as well
Re:If Not React, Then What? by boredtofears on Sunday December 01, 2024 @09:59AM (#42288750)
Yeah that's what I thought -- all the React codebases that I've worked in are riddled with `useEffect` for this reason primarily.
Re:If Not React, Then What? by crvst on Monday December 02, 2024 @03:53AM (#42294374)
I'm jealous, then. I've seen all kinds of deranged Rube Goldberg machines built using useEffect