codeforboston / communityconnect

MIT License
23 stars 61 forks source link

Start Using React Hooks #386

Open johnpyp opened 5 years ago

johnpyp commented 5 years ago

I think it could be valuable to start using the relatively new, and officially recommended, api of React Hooks. React hooks are a way of replacing classes in React, which come with many issues (such as understanding classes, understanding this, higher order components, and render props, to name a few).

This "Introducing Hooks" piece outlines the main reasons to use hooks now, and how you can start to integrate it: https://reactjs.org/docs/hooks-intro.html.

Functional components built with Hooks are completely compatible with Class components, and I believe they are much more readable and understandable, especially for newcomers who may not be familiar with the complex (and, in my opinion, convoluted and unnecessarily confusing) nature of javascript Classes. Facebook is writing all their newly written components in Hooks for these reasons, and others outlined in the "Introducing Hooks" piece.

RajChaudhry commented 5 years ago

Huh, this is really interesting. This can make life a lot easier for new developers confused with lifecycle class methods. Lemme read into this a bit more, but so far i'm a fan, especially if implementing hooks are as easy as these articles say it is.

Leftere commented 5 years ago

I'm relatively familiar with hooks and I think they are awesome. They can also replace redux but its important to first understand how redux works.