invertase / invertase/tanstack-query-firebase
useFirestoreInfiniteQuery fetchNextPage() causes error.
- Dominant language
- TypeScript
- Stars
- 462
- Forks
- 69
- PR merge metrics
- No merged PRs in 30d
Description
The error:
Unhandled Runtime Error
FirebaseError: Function startAfter() called with invalid data. Unsupported field value: undefined
I get this error, when I click on the Load More button twice, my collection has no more documents, but seems like the button is not disabled and lastDocument is undefined which gets passed to startAfter().
```
const posts = useFirestoreInfiniteQuery("posts", postsQuery, (snapshot) => {
const lastDocument = snapshot.docs[snapshot.docs.length - 1];
// Get the next 20 documents starting after the last document fetched.
return query(postsQuery, startAfter(lastDocument));
});
```
fetchNextPage() causes this error.
```
const posts = useFirestoreInfiniteQuery(...);
posts.fetchNextPage()}
>
Load More
```
What is the reason for this bug?
Contributor guide
Assessment
This issue has not been assessed yet.