GithubHelp home page GithubHelp logo

react-shopping-cart's Introduction

Shopping Cart Built in React JS with Context API and useReducer

React Shopping Cart

This project is a simple shopping cart application built using React JS, Context API, and useReducer. It provides a straightforward example of managing state in a React application with the help of Context and useReducer to handle the shopping cart functionality.

Features

  • Add Products: Easily add products to the shopping cart.
  • Remove Products: Remove items from the cart with a simple click.
  • Quantity Control: Adjust the quantity of each product in the cart.
  • Total Calculation: Real-time calculation of the total price based on the items in the cart.

Technologies Used

  • React JS: A JavaScript library for building user interfaces.
  • Context API: A React feature that enables the sharing of state between components without the need for prop drilling.
  • useReducer: A React hook for managing complex state logic in a more organized manner.
  • CSS: Styling is done using CSS for a clean and responsive design.

How to Run

  1. Clone this repository to your local machine.

    git clone https://github.com/your-username/react-shopping-cart.git
    
  2. Navigate to the project directory.

    cd react-shopping-cart
    
  3. Install dependencies.

    npm install
    
  4. Run the application.

    npm start
    
  5. Open your browser and visit http://localhost:3000.

Project Structure

react-shopping-cart/
│
├── src/
│   ├── components/
│   │   ├── Cart.js
│   │   ├── Product.js
│   │   ├── ProductList.js
│   │   └── ShoppingCart.js
│   │
│   ├── context/
│   │   └── CartContext.js
│   │
│   ├── reducers/
│   │   └── cartReducer.js
│   │
│   ├── App.js
│   ├── index.js
│   └── styles.css
│
├── .gitignore
├── package.json
├── README.md
└── LICENSE

Contributing

Contributions are welcome! Feel free to submit issues and pull requests.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Happy coding!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.