Cannot close modal


I created a simple shopping list app. The last thing that i implemented was a function to calculate the total but after this i cannot close the modal because the error message says: Cannot read property ‘price’ of undefined.

this is the repository i put the code:


In onDismiss() handler in update() method (in home.js) you don’t check if the product is returned (and in the case when using the exit() method in the modal it’s not), add the following check and it should fix the problem:

  // home.js
  update(product) {
    let modal = Modal.create(ModalCartPage, {params: product});
    modal.onDismiss((product) => {
      // NOTE: Perform these operations only when a product is returned.
      if (product) {
        // update product
        // re-calculate total:
        this.totalPrice = this.dao.totalPrice();


worked! But in the create method. So i put the conditional in update and create. Thanks for the hint!