title: How to avoid "Excessive number of pending callbacks: 501" error during images download in React Native?
body: <p>I need to download a collection of images on button press. Currently, I'm doing it this way using <code>react-native-fs</code>: </p>
  
  <pre><code>const downloadImageItem = async (imgUrl, id) =&gt; {
    const path = `${RNFS.DocumentDirectoryPath}/${id}.jpg`;
  
    RNFS.downloadFile({
      fromUrl: imgUrl,
      toFile: path,
    });
  };
  </code></pre>
  
  <pre><code>const downloadImages = async (items) =&gt; {
    for (const item of items) {
      if (item.images.length) {
        await downloadImageItem(item.images[0].thumb, item.images[0].id);
      }
    }
    return Promise.resolve();
  };
  </code></pre>
  
  <p>Calling the function from my reducer for 3 types of items:</p>
  
  <pre><code>await downloadImages(items_one);
  await downloadImages(items_two);
  await downloadImages(items_three);
  </code></pre>
  
  <p>My issue is that sometimes I receive an error message that says:
  <strong><em>Excessive number of pending callbacks: 501</em></strong></p>
  
  <p>Is there a better way of doing the same thing, so that the error does not appear?</p>