Hands-On Coding Exercises
Exercise 1: Building a To-Do List App
Objectives:
Create a functional To-Do List application.
Practice state management using
useState
.Implement adding, editing, and deleting tasks.
Use conditional rendering to display tasks based on their status (completed or pending).
Guidelines:
Create a
ToDoList
component to manage the list of tasks.Create a
ToDoItem
component to represent each task.Use
useState
to manage the state of tasks.Implement functions to add, edit, and delete tasks.
Use conditional rendering to display tasks based on their status.
Exercise 2: Building a Weather App
Objectives:
Create a Weather application that fetches data from a weather API.
Practice using
useEffect
for data fetching.Manage global state using Context to share data between components.
Display weather information dynamically based on user input (city name).
Guidelines:
Set up a weather API key and URL.
Create a
WeatherProvider
using Context to manage global state.Use
useEffect
to fetch weather data when the component mounts.Create a
SearchBar
component to allow users to input the city name.Display the fetched weather information in a
WeatherDisplay
component.
Exercise 3: Building a Shopping Cart
Objectives:
Create a Shopping Cart application.
Practice using
useReducer
for managing complex state logic.Implement adding, removing, and updating the quantity of items in the cart.
Use Context to provide cart state and actions to multiple components.
Guidelines:
Create a
CartProvider
using Context anduseReducer
.Define actions for adding, removing, and updating items in the cart.
Create components for displaying products and the shopping cart.
Implement functions to handle adding, removing, and updating items.
Display the total price and item count dynamically.
Help us improve the content 🤩
You can leave comments here.
Last updated