title: Render item from an array after a fixed interval in React
body: <p>I want to array items on after another. But it is only displaying the last element of the array.</p>
  
  <p>Expected output is displaying "a" after 2 seconds "b" and so on.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="true">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>class Main extends React.Component {
    constructor(props) {
      super(props)
      this.state = {
        role: ["a","b","c"],
        display: "",
      }
    }
    componentDidMount() {
      for (let i of this.state.role) {
        setTimeout(() =&gt; {
          this.setState({ display: i})
        }, 2000)
      }
    }
  
    render() {
      return (
        &lt;div&gt;
            &lt;h3&gt;{this.state.display}&lt;/h3&gt;
        &lt;/div&gt;
      )
    }
  }
  
  ReactDOM.render(&lt;Main /&gt;, document.getElementById('root'))</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.6.3/umd/react.production.min.js"&gt;&lt;/script&gt;
  &lt;script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.6.3/umd/react-dom.production.min.js"&gt;&lt;/script&gt;
  
  &lt;div id='root'&gt;&lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>