PINIA_COLADA_R0008: missing getPreviousPageParam
- Level: error (thrown, dev only)
What happened
loadPreviousPage() was called on an infinite query that does not define getPreviousPageParam in its options. Without it, Pinia Colada cannot compute the parameter of the previous page. This will fail in production where the development check is removed.
How to fix it
Add a getPreviousPageParam() function to the useInfiniteQuery() options:
ts
useInfiniteQuery({
key: ['messages'],
query: ({ pageParam }) => fetchMessages({ cursor: pageParam }),
initialPageParam: null as string | null,
getNextPageParam: (lastPage) => lastPage.nextCursor,
getPreviousPageParam: (firstPage) => firstPage.previousCursor,
})Common causes
- Calling
loadPreviousPage()on a query that only paginates forward - Forgetting
getPreviousPageParamwhen adding bidirectional pagination