title: How to set snapshot limit dynamically for Firebase pagination
body: <p>I try to build a flatlist which receives images from Firebase which use pagination.
  The images are sorted by timestamp in descending order, so that the newest images is shown on top.</p>
  <pre><code>this.imageSubscribtion = await this.ref
    .orderBy('timestamp', 'desc')
    .limit(this.state.limit)
    .onSnapshot(async querySnapshot =&gt; {
      let imagesProm = querySnapshot.docs.map(async doc =&gt; {
      
        let data = await doc.data()
  
        return {
         ...data
        };
      });
  
      let images = await Promise.all(imagesProm);
      this.setState(
        {
          pointer: querySnapshot.docs[querySnapshot.docs.length - 1],
          images: images, //.reverse(),
          isLoading: false,
        }
      );
    });
  </code></pre>
  <p>If the user reaches the end of the list, it will load 30 items more.</p>
  <pre><code>if (this.state.pointer) {
    this.setState({refreshing: true}, async () =&gt; {
      let result = await this.ref
        .orderBy('timestamp', 'desc')
        .limit(30)
        .startAfter(this.state.pointer)
        .get();
  
      let imageRefs = result.docs.map(async doc =&gt; {
        let data = await doc.data()
        return {
          ...data
        };
      });
      let images = await Promise.all(imageRefs);
      let newImages = this.state.images.concat(images);
      this.setState(
        {
          pointer: result.docs[result.docs.length - 1],
          images: newImages,
          refreshing: false,
          limit: newImages.length,
        });
    });
  }
  </code></pre>
  <p>This works quite good and all the new images are added correctly.</p>
  <p>The problem starts when new images are uploaded. When the onsnapshot method of the imageSubscribtion is fired the new images are loaded, but again with the initial limit of 30 items.</p>
  <p>If someone is viewing the images at the moment and is down below 30 images the flatlist is resetted to 30 images and he needs to scroll down again.</p>
  <p>Is there a possibility to set the limit of the query dynamically? I also tried to define the query with startAt(this.state.pointer) but its not working because in the first fetch the pointer is still undefined.</p>