Product component

The Product component will render the product details, include an add to cart option, and also show a list of related products:

The Product component can be accessed in the browser at the /product/:productID route, which is defined in MainRouter as follows.

mern-marketplace/client/MainRouter.js:

<Route path="/product/:productId" component={Product}/>

The product details and the related list data will be fetched when the component mounts or will receive new props when the productId changes in the frontend route path after the user clicks on another product in the related list.

mern-marketplace/client/product/Product.js:

Get Full-Stack React Projects now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.