This repo contains a simple example of Context API usage
- Fork and clone this repo
- Run
npm ci
to install dependencies npm run dev
to run the app
The main
branch shows the completed Context-based approach.
Checkout the start
branch which begins with the prop-drilling based approach, and work from there.
- Replace prop drilling with Context API
- Do this for all components
- Implement local storage in CreatePost so that WIP posts are not lost on page refresh
- On first load, check if local storage has any data to initialise the state value
- On input/textarea change,
setPost
AND set/update local storage - On form submit,
setPosts
AND clear local storage