In this lab, we’ll build a Task Manager application that allows users to add, complete, and search tasks. Utilizing the hooks of useRef to persist values without re-rendering, useId to generate unique IDs for accessibility and controlled components, and useContext for global state management.
The frontend is set up, but the application lacks interactivity and state management.
As a user, I should be able to:
- Add a new task using a form (
useId) - Mark tasks as completed (
useContext) - Search tasks dynamically (
useRef)
Determine state and props needed for each component:
- Global states (
useContext) - Persistent Values (
useRef) - Unique IDs (
useId)
- Create
TaskProvideras global state withinTaskContext.jsx - Replace tasks state in app with context
- Implement
toggleCompletefunction withinTaskContext.jsx - Call
toggleCompleteupon clicking task button
- Apply
useIdon form input - Implement
addTaskfunction withinTaskContext.jsx - Call
addTaskwithin submit
- Implement
useRefon search input - Implement filter on task context
Debug and test during development using the provided test suite and React DevTools in Chrome.
- Commit as you go, writing meaningful commit messages
- Push commit history to GitHub periodically and when lab is complete
- GitHub Repo:
useRef: React useRefuseContext: React useContextuseId: React useId
Before we begin coding, let's complete the initial setup for this lesson:
- Go to the provided GitHub repository link.
- Fork the repository to your GitHub account.
- Clone the forked repository to your local machine.
- Open the project in VSCode.
- Run
npm installto install all necessary dependencies.
The frontend is set up, but the application lacks interactivity and state management.
As a user, I should be able to:
- Add a new task using a form (
useId) - Mark tasks as completed (
useContext) - Search tasks dynamically (
useRef)
Determine state and props needed for each component.
npm run devnpm run servernpm run test- Create
TaskProvideras global state withinTaskContext.jsx - Replace tasks state in app with context
- Update
Appwithinmain.jsxto be wrapped inTaskProvider
- Implement
toggleCompletefunction withinTaskContext.jsx - Ensure
toggleCompletefunction edits both thedb.jsonand page - Call
toggleCompleteupon clicking task button
- Apply
useIdon form input - Implement
addTaskfunction withinTaskContext.jsx - Call
addTaskwithin submit
- Implement
useRefon search input - Implement filter task context on
TaskList
- Merge to main
- Add comments to code to explain purpose and logic
- Clarify intent/functionality of code to other developers
- Add screenshot of completed work included in Markdown in
README.md - Update
README.mdtext to reflect the functionality of the application following Make a README - Delete any stale branches on GitHub
- Remove unnecessary/commented-out code
- If needed, update
.gitignoreto remove sensitive data
Once all tests are passing and working code is pushed to the GitHub main branch, submit your GitHub repo through Canvas using CodeGrade.
The application passes all test suites.
Ensure the application:
- Loads tasks with context.
- Submits new task with
useId - Marks tasks as complete.
- Filters tasks shown on the page by a search input.