title: Is it a bad Idea to set state in a while loop?
body: <p>Im having an issue with a while loop and set state. Basically I have a really simple bit of code that takes a random number and adds it a value stored in the state. But when I do something like this:</p>
  
  <pre><code>updateScore(){
      let random = Math.floor(Math.random()*10);
      this.setState({points: this.state.points + random});
      console.log(random);
  }
  </code></pre>
  
  <p>and then call this function in a while loop</p>
  
  <pre><code>while(this.state.points &lt; 20){
      updateScore()
  }
  </code></pre>
  
  <p>I get an infinite loop of random numbers being logged in the console. 
  If I change the while to if it works perfectly fine. Am I doing something wrong or is it just not a good idea to use set State with loops?</p>