Created
August 7, 2019 00:59
-
-
Save codingnninja/6626298d2abb0c17bc2bd6223ade3272 to your computer and use it in GitHub Desktop.
Update food items.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
updateFoodItem(event) { | |
event.preventDefault(); | |
const updatedFood = this.state.food; | |
const updatedCost = this.state.cost; | |
const updatedFoodItem = Object.assign({}, this.state.foodItem, { food: updatedFood, cost: updatedCost }) | |
const foodItems = this.state.foodItems.map((foodItem) => (foodItem.id === this.state.foodItem.id ? updatedFoodItem : foodItem)); | |
this.setState({ food:'', cost: '', foodItems: foodItems}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment