Example App from my Practical Hooks talk
I created Pull Requests detailing each step, to make it easy to see diffs along the way. Each pull request has notes on the specific steps taken:
- Step 1 - Convert Filter component
- Step 2 - Convert SelectUsers component
- Step 3 - Create useLoad custom hook and integrate into App component
- Step 4 - Convert Todos component
- Bonus Step 5 - Move api client into Context
- Bonus Step 6 - Create a UserFilter Context and Custom Hook
Feel free to leave comments or questions in issues or the PRs - would be happy to discuss anything!
General Hooks Resources:
Here are some resources I've found helpful:
An invaluable resource, expecially Hooks DocsHooks Reference and Hooks FAQs
useEffectto throw an error when an effect has run too many times at once. Prevents crashing your browser when you've messed up an effect dependency and created an infinite loop.
useEffect; really helped me understand how to deal with effect dependencies and their relationship with the render.
If you'd like to run this locally:
This project was bootstrapped with Create React App.
To install, clone the repo, then run
In the project directory, you can run:
Runs the app in the development mode.
Open http://localhost:3000 to view it in the browser.
The page will reload if you make edits.
You will also see any lint errors in the console.
Launches the test runner in the interactive watch mode.
See the section about running tests for more information.
yarn run build
Builds the app for production to the
It correctly bundles React in production mode and optimizes the build for the best performance.
The build is minified and the filenames include the hashes.
Your app is ready to be deployed!
See the section about deployment for more information.
You can learn more in the Create React App documentation.
To learn React, check out the React documentation.