Q:

Failing to update a state which is an object

I have a react state which stores:
permissionValue:  [{user_id: 1, landing: true, skadi: true, heimdall: true, register: true, …}]

And I want to update that state. So I do
handleChangePermissions = evt => {
  console.log(this.state.permissionValue); //I can see the initial state
  console.log("id: " + evt.target.id); //Thats the proper key
  console.log("checked: " + evt.target.checked); //Thats the proper value

  var data = this.state.permissionValue[0]; //I store the content of the array in data
  console.log("data1");
  console.log(data); //I can see the array data
  data.evt.target.id = evt.target.checked; //I set the data , supposedly, but I receive " Cannot read property 'target' of undefined "
  //Crashes
  console.log("data2");
  console.log(data);
  console.log("----");
  this.setState({
    permissionValue: data
  });
};

But it crashes when reading evt during the setting of the data. What's the issue?

A:

Solved
handleChangePermissions = (evt) => {
    console.log(this.state.permissionValue) 
    console.log("id: " + evt.target.id) 
    var idu = evt.target.id;
    var checked = evt.target.checked
    console.log("checked: " + evt.target.checked) 

    var data = this.state.permissionValue[0]; 
    console.log("data1")
    console.log(data) 
     data[idu] = checked; 
     console.log("data2")
     console.log(data)

       this.setState({
           permissionValue: [data]
      })

}

