Today you should just use
Today you should just use
usePaginatedQuery
from Convex. You can mix and match these, most of the Convex ones are re-exported as useConvexQuery etc.6 Replies
But for some reason, usePaginatedQuery does not cache to query result. By using it with Tanstack query, I thought it could help the cache issue. Seems like
usePaginatedQuery
deletes the cache once the component is unmounted.Ah got it, yeah we should fix that more generally for everyone that wants cached queries, not just TanStack. Can you lift the query to a parent component that remains mounted for now?
I guess that's the only solution so far. Will usePaginatedQuery support tanstack in the future?
Either we'll use the TanStack Query hooks or we'll make a new hook for this.
Everyone could benefit from a cached-query version (I like to call these "stay subscribed" since cache is do overloaded) so the suggested solution may be the same new hook whether you're using TanStack Query or not.
@ballingt any update on this?
Re caching the query result across pages without raising up the state, no. But usePaginatedQuery works well for most cases.