title: React Native Firestore pagination issue
body: <p>I'm working on a project using React-Native and the react-native-firebase librairy.</p>
  <p>Within this project i'm trying to implement simple pagination with next and previous buttons.
  I'm using startAfter() / limit() for the next one and endBefore() / limitTolast() for the previous one.</p>
  <p>Here is my code</p>
  <pre><code>useEffect(() =&gt; {
  
          setCurrentPage(1)
          setViews([])
          setLoading(true)
          firestore()
          .collection('feed')
          .orderBy(&quot;creation&quot;, &quot;desc&quot;)
          .limit(limit)
          .get()
          .then((snapshot) =&gt; {
                  const data = snapshot.docs.map(doc =&gt; doc.data())
                  const lastVisibleDoc = snapshot.docs[snapshot.docs.length - 1]
                  const firstVisibleDoc = snapshot.docs[0]
                  setViews(data)
                  setLastVisible(lastVisibleDoc)
                  setFirstVisible(firstVisibleDoc)
                  setLoading(false)
          })
      }, [currentUserPreference])
  
  </code></pre>
  <p>This one part will get the first shot of data and works just fine.</p>
  <pre><code>const nextPage = () =&gt; {
  
          setCurrentPage(currentPage + 1)
        
            setLoading(true)
            scrollRef?.current?.scrollTo({y: 0, animated: true})
              firestore()
              .collection('feed')
              .orderBy(&quot;creation&quot;, &quot;desc&quot;)
              .startAfter(lastVisible)
              .limit(limit)
              .get()
              .then((snapshot) =&gt; {
                const data = snapshot.docs.map((doc) =&gt; doc.data())
                const lastVisibleDoc = snapshot.docs[snapshot.docs.length - 1]
                const firstVisibleDoc = snapshot.docs[0]
                setViews(data)
                setLastVisible(lastVisibleDoc)
                setFirstVisible(firstVisibleDoc)
                console.log('fv', firstVisibleDoc)
            })
            console.log(&quot;more&quot;)
            setLoading(false)
  </code></pre>
  <p>This one is to get the next docs works as it should as well.</p>
  <pre><code>const lastPage = () =&gt; {
  
        setCurrentPage(currentPage - 1)
        
          setLoading(true)
          scrollRef?.current?.scrollTo({y: 0, animated: true})
          firestore()
          .collection('feed')
          .orderBy(&quot;creation&quot;, &quot;desc&quot;)
          .endBefore(firstVisible)  
          .limitToLast(limit)
          .get()
          .then((snapshot) =&gt; {
            const data = snapshot.docs.map((doc) =&gt; doc.data())
            const lastVisibleDoc = snapshot.docs[snapshot.docs.length - 1]
            const firstVisibleDoc = snapshot.docs[0]
            console.log('ld', data)
            console.log('lvlp', lastVisibleDoc)
            console.log('lvlp', firstVisibleDoc)
            setViews(data)
            setLastVisible(lastVisibleDoc)        
            setFirstVisible(firstVisibleDoc)   
        })
        console.log(&quot;less&quot;)
        setLoading(false)
  </code></pre>
  <p>This is where the issue is located. My request seems to be off at some point because it doesn't return me anything it doesn't reach 'then' either as my state values doesn't get updated and i don't get the logs i placed in there.
  It doesn't give me any warnings or errors. As i keep track of the current page within a state it gets updated but that's the only thing. Other than that nothing, it stays on the same page with the previous data displayed.</p>
  <p>--Update--</p>
  <p>After trying it using async/await the output is the same but i got some informations out of it.
  Here is the code</p>
  <pre><code>const lastPage = async () =&gt; {
  
        setCurrentPage(currentPage - 1)
  
        console.log(&quot;visibleNow&quot;, firstVisible)
  
        const data = firestore()
        .collection('feed')
        .orderBy(&quot;creation&quot;, &quot;desc&quot;)
        .endBefore(firstVisible)  
        .limitToLast(limit)
  
        console.log(&quot;fdata&quot;, data)
  
        const snapshot = await data.get()
  
        console.log(&quot;snapshot&quot;, snapshot.docs)
  </code></pre>
  <p>Here my two first logs are coming correctly only the log for the snapshot doesn't get reached. I also tried using firstVisible.data() to use the actual data as cursor without all the firebase stuffs but then my snapshot log return me an empty array</p>
  <p>--Update 2--</p>
  <p>The issue seems to come from limitToLast(). When i removed it my query works as expected without this limitation it was loading the whole previous data tho. My limit is a simple value a number but i tried to provide it directly within the limitToLast(2) like so, still it doesn't work</p>
  <p>I don't know where is the mistake, if you have any idea, i will take it.</p>
  <p>Thanks for your help !</p>