🛒 Grocery List App

A React Learning Project - Interactive Grocery Shopping Interface

🎯 Try the App

Click the buttons below to add items to your cart!

📖 About This Project

This is a simple but educational React application that demonstrates fundamental concepts in modern web development. The app features interactive grocery item buttons that, when clicked, show an alert confirming the item has been added to the cart.

🏗️ Project Structure

grocery/ ├── src/ │ ├── main.jsx # Entry point - renders the app │ ├── App.jsx # Main App component │ ├── GroceryItem.jsx # Grocery item component │ └── index.css # Global styles ├── index.html # HTML template ├── package.json # Dependencies and scripts ├── vite.config.js # Vite configuration └── dist/ # Production build

💻 Code Explanation

GroceryItem Component (GroceryItem.jsx)

function GroceryItem(props) { function clickHandler() { alert(props.name + " has been added to the cart"); } return ( <button onClick={clickHandler}> {props.name} </button> ); }

A reusable component that renders a button for each grocery item. When clicked, it shows an alert with the item name.

App Component (App.jsx)

function App() { return ( <div> <h1>🛒 Grocery List</h1> <div className="grocery-grid"> <GroceryItem name="Eggs" /> <GroceryItem name="Banana" /> <GroceryItem name="Strawberry" /> <GroceryItem name="Bread" /> </div> </div> ); }

The root component that renders the title and multiple GroceryItem components in a responsive grid layout.

🛠️ Tech Stack

React 19.1.1
Vite 7.1.2
JSX
ES6 Modules
CSS3
Cloudflare Pages

🎓 Key Learning Points

🚀 Deployment to Cloudflare Pages

This project is deployed using Cloudflare Pages, a fast and reliable hosting platform for static sites.

Deployment Steps:

  1. Build the project: npm run build
  2. Install Wrangler CLI: npm install -g wrangler
  3. Deploy to Cloudflare Pages: wrangler pages deploy dist --project-name grocery-app
  4. Your site is live automatically!

Build Configuration

// vite.config.js import { defineConfig } from 'vite' import react from '@vitejs/plugin-react' export default defineConfig({ plugins: [react()], })

🔧 Development Commands

📚 Next Steps

🌎 View Live Demo