title: setState inside for loop does not update the state: React+Typescript
body: <p>I am having an array of objects which is a state object that corresponds to a user account. Just for a validation purpose if any one of the  object property within array is empty, I am setting a validation property of state object to false. Since I am looping using for loop, the setState is not setting data.</p>
  
  <pre><code> this.state = {
        accounts: [{firstname:"",lastname:"",age:""}],
        validated: true
   };
  
  
  onAdd = () =&gt; {
  
      let { accounts,validated } =  this.state;
      for(let i=0; i&lt; accounts.length; i++){
        if(accounts[i].firstname === '' || accounts[i].age === '')
        {
          this.setState({validated: false},() =&gt; {}); // value is not getting set
          break;
        }
      }
      if(validated)
      {
        // some other operation 
        this.setState({validated: true},() =&gt; {});
      }
    }
  
  render(){
  
     let { validated } =  this.state;
     return(
       {validated ? &lt;span&gt;Please fill in the details&lt;/span&gt; : null}
         //based on the validated flag displaying the error message
     )
  }
  </code></pre>