Skip to content

About

Boolean Tech Academy - Exercise 40/50: React Context API. Extend the mini e-commerce application by introducing React Context API to manage a shared budget mode, allowing users to filter products based on their price.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

12 Commits

Folders and files

Repository files navigation

Static Badge

Exercise 40/50: React Context API

Extend the mini e-commerce application by introducing React Context API to manage a shared budget mode, allowing users to filter products based on their price.

Project overview

Repository Project Category Main Focus Exercise
react-context-api React Context API Exercise React Context, dynamic filtering 40/50

Assignment

Implement a shared context to manage the application's budget mode and control which products are displayed in the store.

Milestone 1: Create the budget context

Create a new context called BudgetContext.

  • Add a boolean state called budgetMode (true / false).
  • Provide the setBudgetMode function to update its value.
  • Wrap the entire application with the BudgetProvider.

Milestone 2: Update the navbar

Create a Navbar.jsx component if one does not already exist.

  • Add the Navbar to App.jsx or to the existing layout component.
  • Include a Budget Mode button that toggles budgetMode when clicked.
  • Dynamically update the button label depending on the current state:
    • Activate Budget Mode
    • Deactivate Budget Mode

Milestone 3: Filter products

Modify the Products page to use the shared context.

  • Retrieve the budgetMode value from BudgetContext.
  • When budgetMode is true, display only products with price <= 30.
  • Otherwise, display all products normally.

Bonus challenge

Turn budget mode into a configurable price filter.

  • Add a numeric maxPrice value to the context, with an initial value of null.
  • Add a number input field to the Navbar, connected to the maxPrice value in the context.
  • In the Products page, display only products with price <= maxPrice.

Important: If maxPrice is null or budgetMode is inactive, display all products, without applying the price filter.

Technologies

JSX CSS JavaScript React Vite

What I learned

  • Creating and managing React Context.
  • Sharing state across multiple components.
  • Implementing a Context Provider.
  • Accessing shared state with useContext.
  • Managing boolean states and toggle functionality.
  • Building dynamic filters based on product prices.
  • Connecting form inputs to shared context values.
  • Combining application state with conditional rendering.

Credits

Exercise assigned by Boolean Tech Academy as part of the Web Development course (Class 152, A.Y. 2025-2026).

About

Boolean Tech Academy - Exercise 40/50: React Context API. Extend the mini e-commerce application by introducing React Context API to manage a shared budget mode, allowing users to filter products based on their price.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages