invertase / invertase/tanstack-query-firebase
Cannot get previousPage when using useFirestoreInfiniteQuery or useFirestoreInfiniteQueryData
- Dominant language
- TypeScript
- Stars
- 462
- Forks
- 69
- PR merge metrics
- No merged PRs in 30d
Description
Looks like the code inside getPreviousPageParam is not even being executed.
Example:
``` javascript
const ordersQuery = query(
collection(firestore, "orders") as CollectionReference,
orderBy("createdAt"),
limit(1)
);
const {
data,
hasPreviousPage,
hasNextPage,
fetchPreviousPage,
fetchNextPage,
} = useFirestoreInfiniteQueryData(
["getOrders"],
ordersQuery,
(snapshot) => {
const lastDocument = snapshot[snapshot.length - 1];
if (!lastDocument) return;
return query(ordersQuery, startAfter(lastDocument.createdAt));
},
{},
{
getPreviousPageParam: (firstPage) => {
const firstOrder = firstPage[0];
return query(ordersQuery, endBefore(firstOrder.createdAt));
},
}
);
```
The result is the same when loading the component and after click a few times in next page button.
`console.log(hasPreviousPage, hasNextPage);`

Also tried to console.log inside getPreviousPageParam and nothing happens.
I'm I doing something wrong?
Contributor guide
Assessment
This issue has not been assessed yet.