react-query-firebase
react-query-firebase copied to clipboard
Cannot get previousPage when using useFirestoreInfiniteQuery or useFirestoreInfiniteQueryData
Looks like the code inside getPreviousPageParam is not even being executed.
Example:
const ordersQuery = query(
collection(firestore, "orders") as CollectionReference<Order>,
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?