A demo on how to use react hooks for everything. DEMO
Concepts:
- Using useState / useContext hooks to create a global observable store
- Providing custom useAppContext hook as an API to the store
- Store mutators are also passed down in context
- Using useState hook as transient component state (errors, input state, etc.)
- Using useEffect hook to run init state
- Using custom hooks (useAdd / useRemove) to handle side effects.
This project is built on top of NextJS for convenience
npm install
npm run dev
- Open your browser and attempt to add / remove items. There is simulated delay with error conditions.