async updated()

in client/src/components/product-item.js [60:78]


  async updated() {
    let testimonials = [];
    const { id, inventory_count } = this.productItem || {};

    // Ensure we are retrieving current product testimonials
    if (this.state.productItem?.id !== id) {
      if (id) {
        testimonials = await getProductTestimonials(id);
      }

      this.state = {
        count: inventory_count,
        testimonials,
      };

      this.state.productItem = this.productItem;
      this.requestUpdate();
    }
  }