Answers for "react state object key value"

2

react state object key value

this.setState(prevState => ({
  food: {
    ...prevState.food,           // copy all other key-value pairs of food object
    pizza: {                     // specific object of food object
      ...prevState.food.pizza,   // copy all pizza key-value pairs
      extraCheese: true          // update value of specific key
    }
  }
}))
Posted by: Guest on July-08-2020

Code answers related to "react state object key value"

Code answers related to "Javascript"

Browse Popular Code Answers by Language