How to update nested state properties in React
Asked 07 September, 2021
Viewed 2.3K times
  • 63
Votes

I'm trying to organize my state by using nested property like this:

this.state = {
   someProperty: {
      flag:true
   }
}

But updating state like this,

this.setState({ someProperty.flag: false });

doesn't work. How can this be done correctly?

30 Answer