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.

Update and reload reviews

Update and reload reviews

Now, we want to be able to update, right? So we want to show the reviews that we have for this product, or review we have if we have one, and then be able to update it, and then reload the reviews so that either the updated one shows or a new one shows, OK? So let's go to the Review Form component. So that's going to be AppRootProductSlugReviewForm. And let's see. We're going to bring in from the Actions, we want to bring in our Get Review by Product ID. And then we're going to go down to the Handle Open, Handle Open Form, which is where we're setting the product ID and user ID and also opening the dialog. And we're going to go under where we set those values. And let's say const review, and set that to await the get review by product ID. And that takes in an object with the product, or product ID rather. And let's see, this actually has to be a sync for this to work. So now we get the review. Then let's check, let's say if review. So if we have one, then we want to set the value. So…

Contents