From the course: Master Next.js by Building Scalable Apps with Routing, Databases, and Performance

Unlock this course with a free trial

Join today to access over 25,200 courses taught by industry experts.

Finishing dynamic cart page

Finishing dynamic cart page

Now, I will implement removeFromCart functionality in the cart page. For that, I will receive the removeProductFromCart function from the useProduct context hook. Let me also give some indentation here to make it look neat. Alright, now I will pass this function to the onClick event of the remove button. So on click the arrow function, remove product from cart and passing the item ID. All right, let me save the code and open the browser. I'll click on the Remove button and you can see that the product is removed from the cart. Let me quickly add some more items in the cart for future testing. Now the user should not select more quantity than it is available for the particular size of the product. So I will disable the plus circle icon button when the quantity is equal to the stock available for a particular size of the product. So I will say disabled is equal to item.quantity is equal to item and in the square brackets I'll say item dot size. All right, let's save and check. I'll…

Contents