title: Firebase Firestore writes only working on the first attempt of a fresh build
body: <p>I've been building an app with Firebase &amp; React Native primarily using Firestore. I started to use Firestore and its been great, but for some reason when writing to Firestore, it is only working on the first attempt (when i remove the app, rebuild, and perform my write).</p>
  <p>I tried to do the exact same thing except write to Firestore and everything works as expected.</p>
  <p>I am also receiving no error!</p>
  <p>Here is what I am doing:</p>
  <pre><code>export const addBrandProduct = (postObj) =&gt; {
    return () =&gt; {
      firebase
        .firestore()
        .collection('brandProducts')
        .add(postObj)
        .then((docRef) =&gt; {
          console.log(&quot;Document written with ID: &quot;, docRef.id);
          Actions.categories();
        })
        .catch(error =&gt; {
          console.error(&quot;Error adding document: &quot;, error);
        });
    };
  };
  </code></pre>
  <p>For more of a reference, here is my component code that calls addBrandProduct()</p>
  <pre><code>  onUploadImages = () =&gt; {
      let photo =
        Platform.OS === 'ios'
          ? this.state.images.map(img =&gt; img.uri.replace('file://', ''))
          : this.state.images.map(img =&gt; img.uri);
  
        photo.forEach((image, i) =&gt; {
        const sessionId = new Date().getTime();
        const Blob = RNFetchBlob.polyfill.Blob;
        const fs = RNFetchBlob.fs;
        window.XMLHttpRequest = RNFetchBlob.polyfill.XMLHttpRequest;
        window.Blob = Blob;
        let uploadBlob = null;
        let mime = 'image/jpg';
        const imageRef = firebase
          .storage()
          .ref('brandProducts/')
          .child(`${this.props.userData.uid}`)
          .child(`${sessionId}-${i}`);
  
        fs.readFile(image, 'base64')
          .then(data =&gt; {
            return Blob.build(data, {type: `${mime};BASE64`});
          })
          .then(blob =&gt; {
            uploadBlob = blob;
            return imageRef.put(blob, {contentType: mime});
          })
          .then(() =&gt; {
            uploadBlob.close();
            return imageRef.getDownloadURL();
          })
          .then(url =&gt; {
            //if this is the last uploaded image, post data to db
            if (i === this.state.images.length - 1) {
              const urls = {
                ...this.state.urls,
                [i]: url,
              };
              const postObj = {
                ...this.state.postObj,
                urls: urls,
              };
              this.props.addBrandProduct(postObj);
            } else {
              this.setState({
                urls: {
                  ...this.state.urls,
                  [i]: url,
                },
              });
            }
          })
          .catch(error =&gt; {
            console.log(error);
          });
      });
    };
  </code></pre>
  <p>Basically, I am uploading a maximum of 3 images along with some data for it. In order to ensure I am uploading them all prior to adding the post data (writing to firestore) I am using a forEach and on the last upload, when it completes, I am calling the action to write the post data.</p>