Book Image

Full-Stack React Projects

By : Shama Hoque
Book Image

Full-Stack React Projects

By: Shama Hoque

Overview of this book

The benefits of using a full JavaScript stack for web development are undeniable, especially when robust and widely adopted technologies such as React, Node, and Express and are available. Combining the power of React with industry-tested, server-side technologies, such as Node, Express, and MongoDB, creates a diverse array of possibilities when developing real-world web applications. This book guides you through preparing the development environment for MERN stack-based web development, to creating a basic skeleton application and extending it to build four different web applications. These applications include a social media, an online marketplace, a media streaming, and a web-based game application with virtual reality features. While learning to set up the stack and developing a diverse range of applications with this book, you will grasp the inner workings of the MERN stack, extend its capabilities for complex features, and gain actionable knowledge of how to prepare MERN-based applications to meet the growing demands of real-world web applications.
Table of Contents (19 chapters)
Title Page
Copyright and Credits
Packt Upsell
Contributors
Preface
Index

Shopping cart


Visitors to the MERN Marketplace can add products they wish to buy to a shopping cart by clicking the add to cart button on each product. A cart icon in the menu will indicate the number of products already added to their cart as the user continues to browse through the marketplace. They can also update the cart contents and begin the checkout by opening the cart view. But to complete checkout and place an order, users will be required to sign in.

The shopping cart is mainly a frontend feature, so the cart details will be stored locally on the client side until the user places the order at checkout. To implement the shopping cart features, we will set up helper methods in client/cart/cart-helper.js to help manipulate the cart details with relevant React components.

Adding to cart

The AddToCart component in client/Cart/AddToCart.js takes a product object and a CSS styles object as props from the parent component it is added to. For example, in MERN Marketplace, it is added to a...