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
TaskProvider
as global state withinTaskContext.jsx
- Replace tasks state in app with context
- Implement
toggleComplete
function withinTaskContext.jsx
- Call
toggleComplete
upon clicking task button
- Apply
useId
on form input - Implement
addTask
function withinTaskContext.jsx
- Call
addTask
within submit
- Implement
useRef
on 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 install
to 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 dev
npm run server
npm run test
- Create
TaskProvider
as global state withinTaskContext.jsx
- Replace tasks state in app with context
- Update
App
withinmain.jsx
to be wrapped inTaskProvider
- Implement
toggleComplete
function withinTaskContext.jsx
- Ensure
toggleComplete
function edits both thedb.json
and page - Call
toggleComplete
upon clicking task button
- Apply
useId
on form input - Implement
addTask
function withinTaskContext.jsx
- Call
addTask
within submit
- Implement
useRef
on 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.md
text 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
.gitignore
to 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.