How get queryCache data correctly #195
-
|
I use const { isLoading } = useQuery({
key: ["emails", props.id],
query: () => emailStore.getIncomingEmail(props.id),
staleTime: 5 * 60 * 1000,
});It works for uncached data: const queryCache = useQueryCache();
onMounted(() => {
const queryData = queryCache.getQueryData(["emails", props.id]);
console.log(queryCache.getEntries());
console.log(queryData);
if (queryData) emailStore.setIncomingEmail(queryData as IncomingEmail);
});Maybe I do something wrong or there are another ways to get cached data to change Pinia state correctly |
Beta Was this translation helpful? Give feedback.
Answered by
posva
Feb 21, 2025
Replies: 1 comment 3 replies
-
|
Since const { isLoading } = useQuery({
key: () => ["emails", props.id],
query: () => emailStore.getIncomingEmail(props.id),
staleTime: 5 * 60 * 1000,
});Right now you are overriding the same entry every time |
Beta Was this translation helpful? Give feedback.
3 replies
Answer selected by
smaylninja
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Since
propsis reactive, you need a getter:Right now you are overriding the same entry every time