title: Issue with setState() in if statement
body: <p>setState() in if statement:</p>
  
  <pre><code>// morePage = true
  // pageNum = 1
  
  if(morePage){
    this.setState({pageNum: this.state.pageNum+1})
  }
  
  console.log(this.state.pageNum); // return: 1
  </code></pre>
  
  <p>setState() out if statement:</p>
  
  <pre><code>// morePage = true
  // pageNum = 1
  
  if(morePage){
    // ... 
  }
  this.setState({pageNum: this.state.pageNum+1})
  
  console.log(this.state.pageNum); // return: 2
  </code></pre>
  
  <p>I'm facing that right now and I would like to know why...</p>
  
  <p>Thanks :)</p>
  
  <p><strong>EDIT AFTER CORRECT ANSWER:</strong></p>
  
  <p>So yeah I should spend more time reading React's Doc :P
  If someone is interested in knowing how I finally did, here is the answer:</p>
  
  <p>In the docs, they say there is no guarantee that your state will have its new value before re-rendering. So you have to use "componentDidUpdate()".</p>
  
  <p>So what I did is, I put the:</p>
  
  <pre><code>this.setState({pageNum: this.state.pageNum+1})
  </code></pre>
  
  <p>inside a random function I've created, after that in the "componentDidUpdate(prevProps, prevState)" function I can access the new and the old props values, and there I can use the previous and the current value of "pageNum" :)</p>