Live data from Hacker News

Kind of annoyed at React

blog.cassidoo.co

41–50 of 135 posts

Re: Kind of annoyed at React

#41
post #18

> it’s not clear/an easily understandable mental model for most people That's already the case, thanks to hooks. Hooks are weird, and should not be taught to junior programmers because it will confuse them for the rest of their careers. Hooks are weird because it doesn't align with functional programming paradigm or with OOP paradigm... it is a new paradigm and it is like nothing else. More on that: https://medium.co…

I'll never understand the "hooks are bad" people. I don't find useEffect confusing, creating custom hooks is a breeze, life is so much better than old class components. When I read complaints about hooks I'm either missing something fundamental about why they're bad, or the people complaining are missing it.

the problem with useEffect is how much it gets used when it doesn’t have to be

its overuse makes it evident that hooks (or React in general) is poorly understood

Re: Kind of annoyed at React

#42
post #35

Earlier quoted context omitted.

And that's why using effects for such tasks is a huge anti pattern. https://react.dev/learn/you-might-not-need-an-effect

The problem is you literally need to use effects to make api requests or access browser apis. You can't get away from it. Maybe you can try and tame the complexity by centralizing this logic as a small team but if the team gets big enough it's fruitless.

Isn't useSyncExternalStore the recommended hook for API requests? And for making API requests I think most people recommend using a library. React-query, RTK or swr for example.

For accessing browser apis useEffects are the way to go, but those are usually extremely easy to understand in my experience. Or just use a library that provides the needed functionality.

Re: Kind of annoyed at React

#43

React is fundamentally bad technology. I know there are historical reasons for the virtual dom but the reasons that justified it don't exist anymore. If you want to do anything interesting with react that involves interacting directly with browser APIs you need to deal with these absurd use effect hoops to initiate state with references to dom nodes. I've worked on 4 large react code bases and they always devolve int…

I've worked in many react codebases, some great some not, and the main predictor of the quality tends to be both the dev lead knowledge, the experience of the team and the learning vs churn out features culture. Same thing used to happen with jQuery BTW, only it was a lot easier to shoot yourself on the foot back then.

I feel like "X new library/framework's code is a mess" is the new "People don't want to work anymore" trope (that older workers have been saying for over 100 years).

Re: Kind of annoyed at React

#44
post #32

Earlier quoted context omitted.

Server components, which are in Next.js (using React's canary branch). Server components are not yet in official (i.e. non-canary) React, and the React team supports this move (as do I). I just wish that the tool that was so helpful with the "other" (100% client-side) React, "Create React App", was better supported these days.

Create React App is in a strange, pseudo-death state. - It is not listed as an option for starting a new project in the React docs[0]. - The last release was April 12, 2022. - The last time I created a new project with CRA, it printed a console log that claimed CRA was deprecated. However, the message seemed to originate from a dependency rather than CRA itself. All this was enough to convince me to move to Next.js f…

I mentioned this upthread, but the "official" deprecation notice is this comment from Dan Abramov in a GitHub issue: https://github.com/reactjs/react.dev/pull/5487#issuecomment-...

Re: Kind of annoyed at React

#45
post #18

Earlier quoted context omitted.

I'll never understand the "hooks are bad" people. I don't find useEffect confusing, creating custom hooks is a breeze, life is so much better than old class components. When I read complaints about hooks I'm either missing something fundamental about why they're bad, or the people complaining are missing it.

"useEffect" itself is not what is confusing. What's confusing is when you have many dozens of components with effects all loading state asynchronously. Some of them might even be executing callbacks passed as props from parent components. Oh, and then those effects sometimes re-execute when the effects of parent components complete and pass down updated props! It actually reminds me of programming VHDL.

If you have dozens of components with dozens of uncontrolled side effects executing in unpredictable order, then nothing is going to help you until you get those effects under control. It'll still be bad architecture with or without hooks.

Re: Kind of annoyed at React

#46
post #33

Earlier quoted context omitted.

> one the best things ever invented Fire? The wheel? Penicillin? Maybe it's just because I'm getting older, but I'm increasingly annoyed when people use these sorts of over-the-top hyperboles.

One of the best things ever invented in component based frontend frameworks. It makes purely functional frameworks like modern react much easier to deal with. Off course it's a violation of some theoretical principals. So what? What I don't get: people complain about not being able to handle all the useEffects, but they probably shouldn't be there in the first place. In my experience most ambiguous use effects can be…

> people complain about not being able to handle all the useEffects, but they probably shouldn't be there in the first place

I think this is the crux of the issue. One's view of hooks depends a lot on the sorts of codebases they've worked in. Maybe the sun has always shone on you, and you've only ever worked in projects where hooks have been used sparingly and with great consideration.

You're very fortunate if so. I've seen some truly horrific hooks-enabled messes that have had to be outright abandoned because they became too complicated for anyone to understand or debug.

Re: Kind of annoyed at React

#47
post #18

> it’s not clear/an easily understandable mental model for most people That's already the case, thanks to hooks. Hooks are weird, and should not be taught to junior programmers because it will confuse them for the rest of their careers. Hooks are weird because it doesn't align with functional programming paradigm or with OOP paradigm... it is a new paradigm and it is like nothing else. More on that: https://medium.co…

I'll never understand the "hooks are bad" people. I don't find useEffect confusing, creating custom hooks is a breeze, life is so much better than old class components. When I read complaints about hooks I'm either missing something fundamental about why they're bad, or the people complaining are missing it.

As someone who was into higher order components but left front end work before hooks were a thing, I’m wondering how the programming experiences are different are different between the two. It seems to me like more or less the same thing but hooks have more magic? Is it just a syntactic difference or are hooks a paradigm shift even further than HOC?

Re: Kind of annoyed at React

#48
post #42

Earlier quoted context omitted.

The problem is you literally need to use effects to make api requests or access browser apis. You can't get away from it. Maybe you can try and tame the complexity by centralizing this logic as a small team but if the team gets big enough it's fruitless.

Isn't useSyncExternalStore the recommended hook for API requests? And for making API requests I think most people recommend using a library. React-query, RTK or swr for example. For accessing browser apis useEffects are the way to go, but those are usually extremely easy to understand in my experience. Or just use a library that provides the needed functionality.

Per the blog post announcing it, it's not recommended that you use that hook directly, only in libraries:

> useSyncExternalStore is intended to be used by libraries, not application code.

https://react.dev/blog/2022/03/29/react-v18#usesyncexternals...

Re: Kind of annoyed at React

#49

React is fundamentally bad technology. I know there are historical reasons for the virtual dom but the reasons that justified it don't exist anymore. If you want to do anything interesting with react that involves interacting directly with browser APIs you need to deal with these absurd use effect hoops to initiate state with references to dom nodes. I've worked on 4 large react code bases and they always devolve int…

React was a massive improvement over Ember.js, Backbone.js and their ilk, which at the time as a young dev I couldn’t grasp by myself.

React, however just clicked. f(state) = UI just makes sense

Re: Kind of annoyed at React

#50
I’ve never gotten into web development but enjoyed developing iOS apps in Obj-C or Android in Java.

Anyone recommend a website framework that might allow me to completely avoid html/css/javascript?

Post reply on HN