React Hooks came out around 4 years ago, and almost any React project made today uses functional components and hooks instead of the class-component model.
If we go to React's documentation a lot of explanation is done using class components, and they don't introduce hooks in the Main Concepts section, don't even mention it in the handling events page.
I think that mixing functional and class components can be misleading and confusing to anyone that wants to learn React as a first JS framework, also frameworks like NextJS made all the documentation using Functional Components.
I'm not saying that people shouldn't learn how to use class components, all the react projects that came out more than 4 years ago use them, but when I learned React some years ago I encounter this issue.
Would you change something about the documentation?
Top comments (14)
I guess you missed it, they are already building the new docs with hooks. beta.reactjs.org/
Oh I didn't see that, it's a hundred times better! Hopefully they release this as standard documentation shortly!
I'm curious about which you learned first? I've never met a new react dev that didn't need a lot of hand holding when going straight to hooks. Admittedly anecdata, but myself and several friends who took on mentees have experienced this. In the cases when I was asked which I teach first and responded "classes", it was meet with surprise. A few weeks later I got reports that mentees could not use hooks properly within a few days but when"downgraded" to classes finally got traction.
Hooks are fine, but they are magical. Nothing about them makes react more "functional".
Will I use hooks? Yes. Will I teach hooks? Eventually. But they are a pedagogical nightmare.
I learnt functional components first (and then hooks). To be honest, I didn't need to use classes since I started with react, maybe because I didn't had to work with a relatively old react project.
In my case I self-taught react, it was my first JS framework, and I tried to learn using react docs, but encounter a lot of confusion because I didn't know which component style should I use, because functional components were relatively new, but every example was made using class components, but at the same time every react project made since then was made using functional components (or at least every project that I encounter), so I had a bit of confusion.
At the end, I ended up learning using other resources because the official documentation was so confusing at that moment, maybe because the hooks update was relatively new.
Finally, React decided to develop a beta version of the docs, that version will replace the actual one with purely functional components and hooks, and the current one will be moved into a "legacy" version, but not the official one.
It's been 4 years since the update came out, and being a framework created by Meta (Facebook) I don't really understand why they didn't change the docs already.
It's just my own experience! Maybe some people didn't have any issues at all!
Ok that all makes sense thanks for sharing 👍
Class components are horrible trust me there is no magic in hooks, It just makes sense and I'm happy we have them.
I've no need to trust you, homie. I'm also happy for you and your amazing journey.
You don't need to trust me, trust the people building React.
Think for yourself.
I learnt React while only utilising the Class Components. It took me a while to accept the Functional Components and the wonders they have to offer. Now I always prefer Functional Components over Class Components. They should have more examples on the way Functional Components can be abused/toyed/utilised.
Yes I have noticed that. They should update the documentation and have a legacy section for the Class syntax.
Yes, they should change it OOP is dead, functional programming is all teh rage now!
Instead of complaining, do the editing yourself and make a pull request (see "edit this page" at the bottom of the page)!
It's not about making a PR to update the docs, React team is building an updated version of the docs using functional components. Some PRs and issues mentioning exactly this were made before, for example here, here, and here. I'm just saying that it's been 4 years since functional components came out and new people coming to React will learn using the old classes instead of the new functional components. The project is open source but managed by Meta not by the community, I think that the documentation should have change some years ago. It's just a subjective opinion!