title: React update state with interval
body: <p>I just start study react and I have question
  Let's say I recive data from server, and I need to add it to my front with some filter.
  Data is array name|age
  I want to add it to front with interval 1sec, so I need to update my state every 1sec, I try some variants and nothing is worked.
  So can someone help me to understude how update state with setState every 1sec?
  Here my code</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>function App() {
      const people = [
          {name: 'David', age: 24},
          {name: 'James', age: 16},
          {name: 'Angela', age: 29},
          {name: 'Gina', age: 28},
          {name: 'Mike', age: 15},
          {name: 'Laura', age: 30},
          {name: 'Paul', age: 25}
      ]
  
      const [btnDisabled, setBtnDisabled] = useState(false)
      const [canDrink, setCanDrink] = useState([])
  
      const interval = function () {
          let i = 0;
          console.log(i)
          const interval = setInterval(() =&gt; {
              console.log(i)
              if (people[i]) {
                  setBtnDisabled(true)
                  if(people[i].age &gt;= 18) {
                      const arr = [...canDrink, people[i]]
                      i++
                      // @ts-ignore
                      setCanDrink(arr)
                  }
              } else {
                  clearInterval(interval)
                  setBtnDisabled(false)
              }
          }, 500)
      }
  
      return (
          &lt;div className="App"&gt;
              &lt;button
                  disabled={btnDisabled}
                  onClick={() =&gt; {
                  interval()
              }}&gt;Interval
              &lt;/button&gt;
              &lt;ul&gt;{canDrink.map( elem =&gt;
                  // @ts-ignore
                  &lt;li key={elem.name}&gt;{ elem.name }&lt;/li&gt;
              )}
              &lt;/ul&gt;
          &lt;/div&gt;
      );
  }</code></pre>
  </div>
  </div>
  </p>