7 ms·
I’m personally becoming frustrated by the “we draw the line at React hooks” idea - which I feel like I’m seeing repeated. Like that’s the point at which learnin
by julianeon 6y ago
I’m personally becoming frustrated by the “we draw the line at React hooks” idea - which I feel like I’m seeing repeated. Like that’s the point at which learning new concepts crosses over from useful exercise to useless extravagance.
So let me say something which is true, but totally against the spirit of this article: there should be 10x as many (!) tutorials about how to implement everything in React using hooks.
My reasoning is pretty simple. For a new learner, unless you have a compelling counter example needing classes, you should use hooks. That’s what you should start off learning and that should be your go-to.
But if you click away from this comment, right now, go to Google, and search for tutorials, despite this “best practice” advice, you’ll see an unholy mess of tutorials citing classes, with a few using hooks as though it’s some kind of new fangled, “out there” tech. I’m talking in the top 10 search results on Google’s front page. In 2020, long after the React team has introduced and explained them.
Look, it’s simple. Aside from their other advantages, hooks make it easier to learn React, with less boilerplate. As a result, it would be better if beginner tutorials were updated to use them. Most have not been.
But I see this complaint regularly, where hooks are trotted out as some kind of example of silly React maximalism. If you learned React then hooks are only going to take up like 2% of the total time budget you’ve already dedicated to learning the framework. It’s not hard, and it’s nothing like learning, say, Haskell. Using hooks to make cheap shots against overcomplicated JS frameworks is unfair, when they’re not overcomplicated and have a perfectly valid reason to exist.
- duxup 6y agoYeah hooks have such a low barrier to entry as far as ... just make a new component with hooks. There is less code, it's easy to do, anyone who has seen a class component doesn't need much of an introduction to understand it. I've got class heavy applications that will stay class heavy, but almost all new components are hooks and they're quick to write, evaluate what is going on, and work with.
- crooked-v 6y agoFor me, the key thing about hooks is that they both make it easier to write everything idemopotently and mostly force you to write everything idemopotently, both of which are great for future code maintenance purposes.
- novaleaf 6y agoI'm just now getting back into webdev after 3 years. Can you please recommend a good tutorial/demo using Hooks? Especially if it's using Typescript! I strongly dislike the create-react-app project because it abstracts everything away.
- julianeon 6y agoFor react hooks: the base results are decent, for that particular search phrase. You won't go wrong with the reactjs docs, prominently placed there. https://reactjs.org/docs/hooks-intro.html https://reactjs.org/docs/hooks-intro.html For react hooks typescript: sorry, I can't. This is a pretty good example of the problem, because I just searched Google's first page of results for react hooks typescript tutuorial, and they were all bad. 3 of very top results seemed to be a derivative of each other, where they presented a list of concepts, which is not really relevant in teaching you to use them. Some of the other ones were a very slight improvement, but still not good enough that I'd feel very comfortable recommending them. On the 1st 2 pages of results, this was the best result I found for react and typescript (not hooks), which at least addresses the topic directly with relevant code. https://www.educative.io/blog/react-and-typescript https://www.educative.io/blog/react-and-typescript Also I want to call out this example for being especially ridiculous, because it titles itself as "Using React Hooks with Typescript" and then doesn't actually use any Typescript! https://blog.usejournal.com/using-react-hooks-with-typescript-aae6c7b2a3a9 https://blog.usejournal.com/using-react-hooks-with-typescrip... Anyway, this nicely illustrates the problem. I may try to write a tutorial on this myself, after seeing how bad these are. But for now, this is what's out there.