From the course: Next.js: Creating and Hosting a Full-Stack Site
Unlock this course with a free trial
Join today to access over 24,800 courses taught by industry experts.
Shopping cart improvements - React.js Tutorial
From the course: Next.js: Creating and Hosting a Full-Stack Site
Shopping cart improvements
- [Instructor] Alright, so now that we've added a button to our products list to add items to the cart, the next thing that we're going to do is make a few improvements to this experience. The first thing we're going to need to do, of course, is make it so that when we click on this button, it doesn't take us to the product detail page, right? Because the button is inside a link component, Next.js just kind of treats the button as a link as well. So even though it also triggers that add to cart functionality, it takes us to the product detail page, which isn't going to be what we want. And we'll also add some styling to that button and make it so that the button displays the correct text, right? Add to cart or remove from cart, depending on whether that item is actually already in the user's cart or not. So here's what that's going to look like. Let's go back over to our editor here. And first things first, let's go into the products list page. That's where the button is at. And this…
Contents
-
-
-
-
-
-
(Locked)
Data loading basics in Next.js1m 13s
-
(Locked)
Loading data with Fetch5m 57s
-
(Locked)
Loading all products3m 39s
-
(Locked)
Loading individual products3m 9s
-
(Locked)
Loading shopping cart items6m 16s
-
(Locked)
Adding items to the cart10m 5s
-
(Locked)
Shopping cart improvements6m 2s
-
(Locked)
Challenge: Removing items from the cart1m 28s
-
(Locked)
Solution: Removing items from the cart5m 34s
-
(Locked)
-
-