title: Recharts chart not updating when using setInterval to periodically append new data
body: <p>I'm trying to set up a web page that adds a score onto a line chart every 2 minutes and it doesn't seem to be working.</p>
  <p>The chart that I am using is the line chart from the Recharts, and the initial value of scoreData is an empty list and the initial form of {time} is {h:0, m:0, s:0}.</p>
  <p>I am using context and hooks so that the page won't stop counting even if the user for some reason temporarily visits other pages that I will be creating.</p>
  <p>The code that I wrote down is as follows;</p>
  <pre><code>const Timer = () =&gt; {
    const {
      scoreData,
      setScoreData,
      time,
      setTime,
      interv,
      setInterv,
    } = useContext(BaseContext);
  
  const addNewData = () =&gt; {
      setScoreData([...score, {Some New data}])
  }
  
  const start = () =&gt; {
      run();
      setInterv(setInterval(run, 1000));
   };
  
  var updatedS = time.s,
      updatedM = time.m,
      updatedH = time.h;
  
    const run = () =&gt; {
      updatedS++;
      if (updatedS === 60) {
        updatedM++;
        updatedS = 0;
        if (updatedM % 2 == 0) {
          addNewData();
          console.log(scoreData.length);
        }
      }
      if (updatedM === 60) {
        updatedH++;
        updatedM = 0;
      }
      return setTime({
        s: updatedS,
        m: updatedM,
        h: updatedH,
      });
    };
  
  return (
  &lt;div&gt;
  // The code of the line chart goes in here.
  
  &lt;button onClick={start}&gt;Start&lt;/button&gt;
  
  &lt;button onClick={addNewData}&gt;Test Button&lt;/button&gt;
  
  &lt;/div&gt;
  )
  </code></pre>
  <p>According to the above code, a new data should be added to the list every two minutes, but the chart never showed any changes.</p>
  <p>When I confirmed the status of the scoreData by using console.log(scoreData.length), the console just showed 0, which means the data is not being appended into the list.</p>
  <p>So I tried a different approach by making a Test Button that manually adds a new data and it worked just fine; the list was filled with new data every time I pushed it.</p>
  <p>In this case, what can I do to make the chart receive the data periodically in accordance to the time that I set up?</p>