title: setState not working for updating an array in React
body: <p>I try to update a <code>state</code> in a location object.
  somehow the setState isn't working for me.</p>
  
  <p>The <code>console.log</code> does return the newName correctly.</p>
  
  <p>I don't see directly where my fault is. Can someone tell me where my error is?</p>
  
  <pre><code>state = {
      locations: [
         {name:"name1", address:"address1", locationSelected:false},
         {name:"name2", address:"address2", locationSelected:false}
      ]
  }
  
  selectLocationHandler = (id) =&gt; {
      let theLocations = [...this.state.locations];
      theLocations[id] = {...theLocations[id], name:"newName!!!!"};
      console.log(theLocations[id].name + "testtest");
  
      this.setState({theLocations}, () =&gt; {
          console.log(this.state.locations[id].name + " it worksss");
      });
  }
  </code></pre>