Hacker News new | ask | show | jobs
by gunshowmo 1545 days ago
The fact that it's been well over 3 years since the introduction of hooks in React and people still don't understand how to use them makes me very worried for frontend development.

Really looking forward to server components.

5 comments

It's also been well over 3 years of myself and many, many other people and teams competently building extensive web apps with React and hooks, so it's not super clear to me in what sense these people "still don't understand how to use them."

There are many reasonable criticisms of hooks, like 1) some people have a strong personal distaste for them, 2) some educators say they're difficult to teach to newcomers, and 3) many people who use them don't have a deep understanding of how they work and how to handle some of the "gotchas." But none of them lead me to conclude that people "still don't understand how to use them."

The JS ecosystem skews younger, not in age, but in years programming. Most people who maybe want to dabble, or fix a script or something, start with JS or Py, and as most of us do, they enjoy programming and venture out to pick up another language along side it. As is the custom, eventually if they chafe against the limitations of JS enough, they move on to something that improves on those, and their newer contributions go there, whether it be typescript, rust, zig, go, and so on.

Looking back at the JS side where the types don't bite, there's a library for everything, and the logos are really good, what we end up with are a lot of first year, or first three year contributions to the ecosystem, so a lot of patterns and algorithms are wisdom lost and aren't present, a lot of libraries are good but not perfect, and there is really no incentive to really dive in and become an expert on a given framework like react, because any day the community might decide, "It's VUE time now" or some such other technology, and suddenly you're the guy using Gulp and Angular on a busted 2021 macbook at the hackathon and people are addressing you as "sir"

There is no incentive to be "the react guy" when it comes to JS ecosystem, that 15 mins is quick.

I am "the react guy" -- but before that I built knockout applications with requirejs & angular applications with coffeescript and gulp, and before that with a 2000 line long script.js & jquery ;)

I don't really disagree with anything you said, except to point out that a lot of the current crop of web devs have never experienced what it is to build an app without any abstraction such as React, and quite understandably have no idea what problems it is doing for them.

I do know that since hopping onto react with all of that ~baggage~ context, I have never wanted to program UIs with a different model. It is true that hooks introduce a layer of abstraction that is sometimes difficult to reason about, but IMO they boil down the problems we faced with class components/lifecycle/server rendering gotchas, and put them front and center - forcing you to confront and fix them rather than settling for a solution that works 99% of the time.

> the current crop of web devs have never experienced what it is to build an app without any abstraction such as React, and quite understandably have no idea what problems it is doing for them.

This is true. A lot of those struggles that the earlier people established, the patterns and best uses, those are lessons learned the hard way, and the impact on generation 2 is often much less because that wasn't a problem that needed to be overcome.

What give you the impression that people don't get hooks? In our company I see zero questions about how hooks work on slack. 90% of the time useEffect is enough.
Yeah I was going to say.. where’s the confusion? Once you learn the 3 or 4 most used hooks you can pretty much achieve everything you would ever need in a web app. It’s not like they aren’t documented well, and there are tons of videos on them.
Do they understand how useEffect actually works? Or do they slap on dependency lists on it because eslint tells them to?

People understand how to use hooks, but I don't think many people understand them.

> Do they understand how useEffect actually works?

What do you mean? If you're asking if they can and do use useEffect for its intended purpose regularly and don't run into edge cases any more often than with any other coding pattern, then yeah, they understand how useEffect actually works. If you're asking if they have a deep technical understanding of how hooks are implemented in the React library and every potential "gotcha" they might ever run into, then sure, probably not, but the same goes for every basic pattern used in any programming language.

I think the magic of frameworks is that engineers can be productive and create actual value without understanding how things actually work under the hood. In the AngularJS days, how many people could honestly say they understood the scope inheritance and digest cycle entirely? Or how in VueJS that objects' setters and getters are replaced with proxies that trigger a rendering cycle?

Honestly, I would say 90% of professional engineers don't understand how these reactivity models actually work under the hood, and that is okay because it's not strictly necessary to get the job done.

That being said, if I ever had a candidate that is in that remaining % of people who not only know how to use the technology, but what it's doing under the hood (and as a bonus, the benefits and drawbacks of a given approach), it would be an enthusiastic two thumbs up from me.

Server components aren't going to fix the problem you're worried about. IMHO, Remix.run is the way forward for React towards a simpler, saner future.
>it's been well over 3 years since the introduction of hooks in React and people still don't understand how to use them

s/how/why/