I am confused how to make pagination with realtime firestore query:
const subscriber = firestore()
.collection('notifications')
.doc(authenticatedUser.uid)
.collection('notificationItems')
.orderBy('createdDate', 'desc')
.limit(5)
.onSnapshot(response => {
setNotifications(response.docs); // Settings all to app state
With this I receive realtime updates from firestore but how to append new data and continue to listen.
If I call this again then I get new subscriber.
Can somebody hint me just how to append new items and continue listening changes?
Just to be clear I am keeping reference to the last item from response and then use startAfter()
to get next item I just don't know how to do the same with onSnapshot