title: How do I set a delay on a file upload in React?
body: <p>I want to batch my records for uploading so I don't create server issues. I would like to be able to push 10 records at a time, every five seconds, just to prove the concept for now. I've put setInterval functions all over my code but can't get it to run at the right time. I've been at this for days but can't figure it out.</p>
  <pre><code>chunkData(data) {
      const maxRecords = 10;
      const loops = (data.length % maxRecords &gt; 0) ? Math.floor(data.length / maxRecords) + 1 : data.length / maxRecords;
      //console.log('data: ', data);
      //console.log('loops: ', loops);
  
      //setInterval(() =&gt; {
          for (let loop = 0; loop &lt; loops; loop++) {
          console.log('loop: ', loop);
          let start = loop * maxRecords;
          //setInterval(() =&gt; {
            for (let batch = start; batch &lt; start + maxRecords; batch++) {
              // the line below will become the upload function once I get this to work
              if (data[batch] !== undefined) console.log('data[batch]: ', data[batch]);
            }
            //start = start + 10;
          //}, 5000);
        }
      //}, 5000);
    }
  </code></pre>
  <p>I'm certain it's a simple tweak I need but I'm clueless as to how to make it happen right now. Any advice would be greatly appreciated.</p>