React. this.setState is not a function inside setTimeout : <p>Current component has <code>state.breaker</code> value of false. When the scroll event is captured it looks at the <code>state</code> and if its <code>false</code> it does some stuff. </p>

<p>I would like to have some kind of static delay before the action will recur and that's why inside <code>goTo</code> function the <code>state.breaker</code> is set to <code>true</code> and will block the the further logic of current method for next <code>2s</code> until <code>setTimeout</code> will return back to <code>false</code>.</p>

<p>But at the current moment the following error occurs <strong><em>Uncaught TypeError: this.setState is not a function</em></strong> when <code>setState</code> is called inside <code>setTimeout</code>.</p>

<pre><code>class Slide extends Component {
  constructor(props) {
    super(props)

    this.state = {
      breaker: false
    }

    this.scrollRedirect = this.scrollRedirect.bind(this);
  }

  componentDidMount() {
    this.refs.holder.addEventListener('mousewheel', this.scrollRedirect);
  }


  scrollRedirect(e) {

    const path = this.props.location.pathname,
    goTo = (route) =&gt; {
      this.setState({breaker: true});
      hashHistory.push(route);

      setTimeout(function () {
        this.setState({breaker: false});
      }, 2000)
    };

    if (!this.state.breaker) {
       ... code that executes goTo on condition
    }
  }

  ... render code

}
</code></pre>
