Fuzzyma
Fuzzyma5h ago

Why isnt `useQuery` returning a cached result right away?

When i use convex.query(someQuery) in a loader and in a sub component i use useQuery(someQuery), the query doesn't return a result right away. I would have expected that the value is cached somehow. Isn't that the case? I would love to use loaders to ensure data is there but i don't want to use useLoaderData() because I loose the real time capabilities of the one-off-query i request in the loader Any insights would be appreciated. The docs say
Convex caches query results automatically. If many clients request the same query, with the same arguments, they will receive a cached response.
So I expected an instant result. But its always undefined first which leads to flashing of wrong component state
Queries | Convex Developer Hub
Fetch data from the database with caching and reactivity
2 Replies
Convex Bot
Convex Bot5h ago
Thanks for posting in <#1088161997662724167>. Reminder: If you have a Convex Pro account, use the Convex Dashboard to file support tickets. - Provide context: What are you trying to achieve, what is the end-user interaction, what are you seeing? (full error message, command output, etc.) - Use search.convex.dev to search Docs, Stack, and Discord all at once. - Additionally, you can post your questions in the Convex Community's <#1228095053885476985> channel to receive a response from AI. - Avoid tagging staff unless specifically instructed. Thank you!

Did you find this page helpful?