Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Update Tutorial to use Hooks instead of class components #1782
I think the react docs are a fantastic place for people to start getting into React. Seems like hooks are where we want people to learn React so it makes sense to update the tutorial to use hooks instead.
Let me know what you think. I'm sure we'd get a lot of people willing to contribute this.
I'm definitely interested to help!
I've actually recreated the Tic Tac Toe tutorial using hooks.
Following are the pens for all the code check points as provided in the tutorial:
I think this approach might be interesting to add as a bonus/advanced section to the tutorial to demonstrate what is possible using custom hooks.
I think the main consideration would be to change the code to using declared functions instead of arrow functions.
I would be very interested to get feedback on the code, and will also gladly help with the documentation as well if you would like to proceed with this.
@abdusabri I'm not super familiar with the tutorial as I preferred to learn React via its docs, but as far as I can tell from the final step of the first solution, this looks like a very solid translation of the original class logic to hooks. My only complaints are ones I'd also have of the original.
The second solution seems to have some pretty good ideas for an advanced tutorial, but I think custom hooks and reducers are a bit much for beginners, and it would be better to do after the first solution.
I started working on the docs (see #1788) but don't have a pull request yet, hopefully will soonish. I'm not sure if the core team is also planning on doing something like this, but I'm hoping that it could at least be useful in the meantime as a fork of the docs for users that prefer hooks.