From the course: Next.js Ecommerce: Build a Shopping Platform from Scratch

Unlock this course with a free trial

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

Display reviews

Display reviews

Now we want to display the reviews on the page. We have everything in place. We can add them. We have the action to get them. So we just need to use that action and display them. Now one thing I want to do real quick is in the types file, so types index, if we go to the product type, I forgot to add the num ratings. So let's just, I'm sorry, num reviews. So we want to add that and let's set that to a number. Okay, so I just wanted to do that first and then we're going to go back into the review list form so root Product slug and then review list and this is where we want to bring in our get reviews action that we created so we want to import get get reviews and We're in a client component, so we're going to bring in use effect so let's say import use effect and And that will be called when the component loads. So let's come down and we'll add this right under the state. So useEffect. And what it's going to take in is a function as well as a dependency array. So anything you put in…

Contents