- Lab
- A Cloud Guru
Building a Grocery List App with React
React is one of the most popular front-end web development frameworks in the world and something worth knowing a little about. It provides a declarative and composable interface to make building user interfaces with complex interactions more manageable. In this hands-on lab, we'll go through building a simple grocery shopping list application from start to finish. To feel comfortable completing this lab, you'll need to know how to do the following: - Create a new React application. - Utilize state and props within React components. - Handle browser events using React components. If you're currently unsure of how to perform any of these actions, consider taking the short **Expanding Your JS Skills with React** course to get up to speed.
Path Info
Table of Contents
-
Challenge
Create the Groceries React Application
Generate a new React application called
groceries
so that we can build the grocery shopping list application.Optional: Add Bulma for Styling
In order to follow along with the styling used in the example solution for this hands-on lab, you'll need bulma.
public/index.html
<!DOCTYPE html> <html lang="en"> <head> <!-- rest of head omitted --> <title>React App</title> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/css/bulma.min.css" /> <script defer src="https://use.fontawesome.com/releases/v5.3.1/js/all.js" ></script> </head> <!-- body omitted --> </html>
-
Challenge
Display a New Item Form and the Grocery Items
The goal of this application is to act as a checklist of groceries that need to be purchased including the grocery item names and the quantity of each. To begin, we'll want to modify our
App
component to display a form that allows us to add a new grocery item and display the items already on our list. -
Challenge
Add the Ability to Add a New Grocery Item
Write the necessary event handling function(s) to allow someone to submit the new grocery item form and have the information added to the application's state. It should also be displayed to the screen.
-
Challenge
Add the Ability to Check Off a Grocery Item
Modify the application so that the user can click the checkbox of a grocery item and have it toggle the
purchased
state of the grocery item in the application's state.
What's a lab?
Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.
Provided environment for hands-on practice
We will provide the credentials and environment necessary for you to practice right within your browser.
Guided walkthrough
Follow along with the author’s guided walkthrough and build something new in your provided environment!
Did you know?
On average, you retain 75% more of your learning if you get time for practice.