title: this.setState makes variable undefined?
body: <p>I'm trying to increment my state variable, but whenever I do so an error pops up which says that the variable state is undefined. <strong>I defined my variable inside the constructor</strong>. Obviously something is going on in the setState function.</p>
  
  <p>Here is the code which renders an error:</p>
  
  <pre><code>displayDiv(){
    var arr=[];
    if (this.state.flag[2]){
      this.setState({counter:counter+4}); // error:undefined
      for (let i = this.state.counter-4; i &lt; this.state.counter; i++)
        arr.push(this.state.arrayHeader[0].content);
      }
    }
   return(
     arr.map(function(item,i){
       return (
         &lt;div className="bodydiv col-sm-3"&gt;
           &lt;Header/&gt;
           &lt;Content/&gt;
           &lt;Tags/&gt;
         &lt;/div&gt;
       );
  
      })
    );
  }
  </code></pre>
  
  <p>Here is the defined variable inside the constructor:</p>
  
  <pre><code>constructor(props){
    super(props);
  
    this.state = {
      arrayHeader:[],
      arraytag1:[],
      arraytag2:[],
      counter:0,
      flag:[false,false,false]
    }
  }
  </code></pre>