let {entries} = this.state.cart;
                  
                  
                  
                  
                  
                      if(this.checkProduct(product.id)){
                  
                  
                        let index = entries.findIndex((x => x.id === product.id));
                  
                  
                  
                  
                  
                        entries[index].quantity = entries[index].quantity + product.quantity;
                  
                  
                      } else {
                  
                  
                        entries.push(product);
                  
                  
                      }
                  
                  
                  
                  
                  
                      this.setState({ cart: { entries }, quantity: 1 });
                  
                  
                    };
                  
                  
                
Юзац превстейт
Пуш мутирует
Обсуждают сегодня