CodeBlanks Logo Icon CodeBlanks

Project: Shopping list

Review the goal and steps of the shopping list project.

Project: Shopping list

In this project we will build a small shopping list app. Three pieces: an Item that draws one row, a ListBody that draws the whole list, and an EmptyState shown when the list is empty.

Each lesson adds one piece; the last lesson joins everything. We keep the data as a fixed array; state comes in later groups.

First we lay out the skeleton: a section and a heading.

Data model

Each item in the shopping list has three fields: id (unique identity), name (product name) and qty (quantity).

Example: { id: 1, name: "Bread", qty: 2 }. We will use id as the key and name as the label. qty shows up later.

Keeping the data fixed makes the components easy to write; interaction comes in later groups.

Practice ShoppingApp skeleton

Complete the skeleton. Write a ShoppingApp component that returns <section> with <h1>Shopping List</h1> inside. Export it.

Starter code

App.jsx
// Define ShoppingApp here

Sample solution

App.jsx
function ShoppingApp() {
  return <section><h1>Shopping List</h1></section>;
}

export default ShoppingApp;

Questions and answers

Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.

1 Which component is written first in this project?

App.jsx
We go from the small piece to the big one.
  • ListBody
  • EmptyState
  • Item Correct answer
  • Router

Explanation: Item comes first; ListBody then calls it.

2 Project: Shopping list: fill in the missing part

Question
<section><h1>____</h1></section>
Answer
<section><h1>Shopping List</h1></section>

Explanation: The heading is an h1 inside section.

3 Project: Shopping list: match the terms

Term Meaning
Item Draws one row
ListBody Draws the whole list
EmptyState Shows empty message
section Outer shell

All lessons in Beginner