The goal of this exercise is to learn how to think in React.
You need to be comfortable writing JavaScript and HTML to do this exercise. The exercise uses the following ES6 & ES5 features:
- Module system (import/ export)
- Class syntax (extends, constructor)
- Arrow functions
- Array.map and Array.filter
You need to have nodeand npminstalled in your computer.
If you find the exercise too difficult we recommend you to do the following basic React course from freeCodeCamp before.
git clone git@github.com:leanjscom/thinking-in-react.git && cd thinking-in-react && npm install && npm start
Before you start, there are two types of components Functional Components and Class Components. Try to use a Functional component if the component doesn't have state, you'll need to refactor code a few times during the next exercise :)
1- Refactor the “about” and “footer” sections by creating a functional component for each. Make sure everything works.
2- Refactor the navbar by creating a Functional Component (AKA stateless components) and pass the dependencies (this.toggleMenu in this case) via props. Make sure everything works by clicking on the "Training" button at the top right of the screen.
3- Refactor the books section by creating a functional component and pass the dependencies via props. Make sure everything works.
4- Is there any state in app that should be in the Books component? Refactor <Books> books if appropriate. Should <Books> be a Functional Component or a Class Component now?
5- Break <Books> down into <BookList> and <BookFilter>
6- What do you think it would make sense to componentize next? Are there any parts on that view that you can reuse? Try to explain to a mentor what you want to refactor before you code :)
- https://medium.com/leanjs/introduction-to-react-3000e9cbcd26
- Basic React course from freeCodeCamp
- https://reactjs.org/docs/introducing-jsx.html
- https://reactjs.org/docs/thinking-in-react.html
- babel repl example
This material is available for private, non-commercial use under the GPL version 3.