title: Is there a synchronous alternative of setState() in Reactjs
body: <p>According to the explaination in the <a href="https://facebook.github.io/react/docs/react-component.html#setstate" rel="noreferrer">docs</a>:</p>
  <blockquote>
  <p>setState() does not immediately mutate this.state but creates a pending state transition. Accessing this.state after calling this method can potentially return the existing value.</p>
  <p>There is no guarantee of synchronous operation of calls to setState and calls may be batched for performance gains.</p>
  </blockquote>
  <p>So since <code>setState()</code> is asyncronous and there is no guarantee about its synchronous performance. Is there an alternative of <code>setState()</code> that is syncronous.</p>
  <p>For example</p>
  <pre><code>//initial value of cnt:0
  this.setState({cnt:this.state.cnt+1})
  alert(this.state.cnt);    //alert value:0
  </code></pre>
  <p>Since the <code>alert</code> value is previous value so what is the alternative that will give <code>alert value:1</code> using <code>setState()</code>.</p>
  <p>There are few questions on Stackoverflow which is similar to this question but no where I am able to find the correct answer.</p>