title: setState in react is not working in react component
body: <p>I'm trying to create a small react component, however, I am unable to set the state. Below is my code. In the <code>_onChange</code> function, I am trying to set an array of length 10 to State and <code>console.log</code> the same. I am getting an empty array in the console.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var Home = React.createClass({
  
      getInitialState: function () {
          return ({
              reviewData: []
          });
      },
  
      componentWillMount: function() {
          ReviewStore.addChangeListener(this._onChange);
          ReviewAction.getRatings();
          console.log(this.state.reviewData);
      },
  
      _onChange: function() {
          var res = ReviewStore.getRating();
          console.log(res); //Here I am getting array of length 10
          this.setState({reviewData: ReviewStore.getRating()});
          console.log(this.state.reviewData); //Here I am getting array of length 0
      },
  
      componentWillUnmount: function () {
          ReviewStore.removeChangeListener(this._onChange);
      },
  
      ratingChanged : function(newRating) {
          console.log(newRating)
      },
  
      render: function() {
          return(
              &lt;div&gt;
                  &lt;h2&gt;Rating of Arlo Smart Home 1 HD Camera&lt;/h2&gt;
                  &lt;hr/&gt;
                  &lt;h4&gt;Average Rating: &lt;/h4&gt;&lt;ReactStars half={false} onChange={this.ratingChanged} size={24}/&gt;
              &lt;/div&gt;
          )
      }
  });</code></pre>
  </div>
  </div>
  </p>