ballingt
ballingt6mo ago

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
Jacob Kim
Jacob Kim6mo ago
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.
ballingt
ballingtOP6mo ago
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?
Jacob Kim
Jacob Kim6mo ago
I guess that's the only solution so far. Will usePaginatedQuery support tanstack in the future?
ballingt
ballingtOP6mo ago
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.
attheclub
attheclub3mo ago
@ballingt any update on this?
ballingt
ballingtOP3mo ago
Re caching the query result across pages without raising up the state, no. But usePaginatedQuery works well for most cases.

Did you find this page helpful?