update old object in react
addIngredientHandler = ( type ) => {
const oldCount = this.state.ingredients[type];
const updatedCount = oldCount + 1;
const updatedIngredients = {
...this.state.ingredients
};
updatedIngredients[type] = updatedCount;
const priceAddition = INGREDIENT_PRICES[type];
const oldPrice = this.state.totalPrice;
const newPrice = oldPrice + priceAddition;
this.setState( { totalPrice: newPrice, ingredients: updatedIngredients } );
this.updatePurchaseState( updatedIngredients );
console.log('3')
}