Build a complete Task Manager app — putting together everything you've learned about React components, state, context, routing, and API calls.
Project Structure
Components
Context (Global State)
Pages
Connecting Everything
Quiz
Project Structure
Think of your project like a well-organized office building. You don't throw all employees into one room — you have departments (folders). The reception (pages) greets visitors, the workers (components) do specific tasks, the manager (context) keeps track of the big picture, and the mail room (api) handles communication with the outside world.
Here's the folder structure for our Task Manager app:
Project — Folder Structure
Why organize like this? When your app grows to 50+ files, having folders like components/, pages/, and context/ means you always know where to find things. Components are reusable pieces, pages are full screens, and context is shared state.
Components
Components are the building blocks of our app. Each one does ONE thing well. Let's build them one by one.
TaskCard — Displaying a Single Task
src/components/TaskCard.jsx
TaskForm — Creating and Editing Tasks
src/components/TaskForm.jsx
TaskList — Rendering Multiple Tasks
src/components/TaskList.jsx
Context (Global State)
Context is like a company-wide memo board. Instead of passing messages from person to person through a chain (prop drilling), you pin the message to the board where anyone in the company can read it. In React, Context lets any component access shared data without passing props through every level.
TaskContext — Managing Tasks Globally
src/context/TaskContext.jsx
The 4-step Context pattern: (1) Create context, (2) Build a Provider component with state + functions, (3) Wrap your app with the Provider, (4) Create a custom hook (useTasks) for clean access. This pattern works for ANY shared state — tasks, auth, themes, etc.
Pages
Pages are full-screen components that map to routes. They use our components and context to create complete views.
TasksPage — The Main Dashboard
src/pages/TasksPage.jsx
Connecting Everything
Now we wire it all together in App.jsx — wrapping with providers and setting up routes:
Provider order matters! Providers must wrap the components that need them. AuthProvider wraps TaskProvider because tasks might need auth info (like the user's token). Always put the most fundamental provider (Auth) at the outermost level.
📝 Chapter 10 Quiz
1. What problem does React Context solve?
Making API calls faster
Styling components
Sharing state without passing props through every level
Creating routes for pages
2. What's the difference between components and pages?
Pages use hooks, components don't
Components are reusable pieces, pages are full screens for routes
There is no difference
Components handle API calls, pages handle UI
3. What does a ProtectedRoute component do?
Redirects to login if the user is not authenticated
Makes the page load faster
Encrypts the page content
Prevents API errors
4. Why create a custom hook like useTasks()?
It's required by React
To make API calls faster
To replace useState
For clean, easy access to context from any component
5. Why does AuthProvider wrap TaskProvider in App.jsx?
Alphabetical order
Tasks may need auth info, so Auth must be available first