Skip to content

Instantly share code, notes, and snippets.

@codingnninja
Last active August 7, 2019 06:31
Show Gist options
  • Save codingnninja/8cb6c07556acecf217c47cad50c4f0df to your computer and use it in GitHub Desktop.
Save codingnninja/8cb6c07556acecf217c47cad50c4f0df to your computer and use it in GitHub Desktop.
Bought food items.
boughtFoodItem(currentFoodItem) {
const updatedCurrentFoodItem = Object.assign({}, currentFoodItem, { status: true });
const foodItems = this.state.foodItems.map((foodItem, index) => (foodItem.id === currentFoodItem.id ? updatedCurrentFoodItem : foodItem));
this.setState({foodItems: foodItems})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment