title: React, 2 setstate in same function: second one erase the first
body: <p>I am trying to run the code above but the state get updated only for idx. From what i understand the second function's setState will not get the updated state and thats why this happens. Is there a way to make it work properly (expect than merge the 2 functions in one)</p>
  
  <pre><code>doIt(idx,array) {
     this.doFirst(array);
     this.doSecond(idx);
  }
  
  doFirst(array){
     //bla bla bla code
     this.setState(test: {...this.state.test, array});
  }
  
  doSecond(idx) {
      // bla bla bla code
      this.setState(test: {...this.state.test, idx});
  }
  </code></pre>