title: React Firebase image url not being saved
body: <p>I want to upload images to FireBase storage and then save the image url to the firebase firestore database. It works 50% of the time but sometimes the url shows up as null.</p>
  <p>CODE:</p>
  <pre><code>const onUpload = async () =&gt; {
      setLoading3(true);
      for (let i = 0; i &lt; campaignImage.length; i += 1) {
      const file = campaignImage[i]
      const storageRef = storage.ref()
      const fileRef = storageRef.child(file.name)
      await fileRef.put(file)
      setUrl(await fileRef.getDownloadURL())
      
      db.collection(&quot;campaigns&quot;).doc(campaignName).update({
        images: firebase.firestore.FieldValue.arrayUnion({
          name: file.name,
          url: url
        })
        
      })
    }
  </code></pre>
  <p>The file name works perfectly but the url sometimes doesn't show. The image upload is always successful but placing the image url into the firestore collection is not working.</p>