title: setTimeout() in componentDidMount() does not work
body: <p>I am trying to change the state of a component every 5 seconds as below inside componentDidMount() hook</p>
  
  <pre><code>import React, { Component } from 'react';
  
  export default class ToTest extends Component {
  
    constructor(props) {
      super(props);
      this.state = {
        test: false
      };
    }
  
    componentDidMount() {
      setTimeout(() =&gt; { this.setState({ test: !this.state.test }) }, 5000);
    }
  
    renderDiv() {
      if(this.state.test) {
        return (&lt;div&gt;test is true&lt;/div&gt;)
      }
      else {
        return (&lt;div&gt;test is false&lt;/div&gt;)
      }
    }
    render() {
      return (
        &lt;div&gt;{ this.renderDiv() }&lt;/div&gt;
      );
    }
  }
  </code></pre>
  
  <p>But it executes only once. It changes from false to true once and then nothing.
  What am I missing?</p>