How to update nested state properties in React

后端 未结 26 1991
野趣味
野趣味 2020-11-21 06:35

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

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

But updating

26条回答
  •  长情又很酷
    2020-11-21 07:12

    stateUpdate = () => {
        let obj = this.state;
        if(this.props.v12_data.values.email) {
          obj.obj_v12.Customer.EmailAddress = this.props.v12_data.values.email
        }
        this.setState(obj)
    }
    

提交回复
热议问题