title: ComponentWillMount doesn't set the state React JS
body: <p>Why this isn't working :</p>
  
  <pre><code>class Slider extends React.Component {
      constructor(props){
          super(props);
  
          this.state = {
              top : 0,
              responsiveImg : ""
          };
      }
  
      componentWillMount(){
          const bodyWidth = window.innerWidth;
          const responsiveSliderImg = "responsiveSliderImg";
  
          if((bodyWidth &gt;= 415) &amp;&amp; (bodyWidth &lt; 473)){
              this.setState({responsiveImg: responsiveSliderImg});
              console.log("The state is : " + this.state.responsiveImg);
          }
      }
  }
  </code></pre>
  
  <p>I'm trying to add a class name to the state in componentWillMount function, but it doesn't work. In console log I get <strong>The state is :</strong> , thus the state is empty.</p>
  
  <p>Any idea?</p>