1 addIngredientHandler = ( type ) => {
2 const oldCount = this.state.ingredients[type];
3 const updatedCount = oldCount + 1;
4 const updatedIngredients = {
5 ...this.state.ingredients
6 };
7 updatedIngredients[type] = updatedCount;
8 const priceAddition = INGREDIENT_PRICES[type];
9 const oldPrice = this.state.totalPrice;
10 const newPrice = oldPrice + priceAddition;
11 this.setState( { totalPrice: newPrice, ingredients: updatedIngredients } );
12 this.updatePurchaseState( updatedIngredients );
13 console.log('3')
14
15 }