
React is ideal when you are building an application that uses a lot of state (data) or involves a lot of DOM manipulation. We'll get a glimpse of the power of React.js through building a simple to-do app. With React.js, it's super easy to build and maintain complex applications. It is open-source and maintained by Facebook. Here’s the starting code.React is a JavaScript library for creating user interfaces. Let’s start adding some functionality! The TodoForm ComponentĪdd a new file, src/TodoForm.js.
It’s already set up with material-ui to give our page a professional look.
The app should be running on localhost:3000, and here’s our initial UI. The master branch has the finished project, so checkout the start branch if you wish to follow along. Here are the GitHub and CodeSandbox links.
Display todos in a nice Material Design fashion. I recommend this for any language or library you want to try out. Todo lists are the most overused example for a good reason - they’re fantastic practice. Instead, they suggest practicing Hooks in non-critical components first, then using them in place of classes going forward. However, since there are no plans to remove classes from React and Hooks will work with existing code, the React team recommends avoiding "big rewrites". React 16.8.0 was the first stable release to support Hooks, and there are more tutorials and example code every day. Adopt Hooks GraduallyĪt the time of writing, Hooks were in alpha, and their API could have changed any time. Avoiding ES6 classes, because they’re quirky, not actually classes, and trip up even experienced JavaScript developers.įor more detail see React’s official Hooks intro.
Separating your app’s concerns based on logic, not lifecycle hooks. Sharing stateful logic without render props or higher-order components. Isolating stateful logic, making it easier to test.
They’re functions that give you React features like state and lifecycle hooks without ES6 classes. React v16.7.0-alpha introduced Hooks, and I’m excited.