TRPC's useContext does not invalidate query.

Still dont know why useContext is not working for me (using .refetch, .invalidate on utils does nothing): I can confirm that onSuccess gets called. It also doesnt work even if I remove the enabled option. It invalidates when I put an override on createTRPCNext but I really don't want to invalidate all the queries in the cache.
const utils = trpc.useContext();
const websites = trpc.website.getWebsites.useQuery(undefined, {
enabled: isAuthenticated,
});
const updateWebsite = trpc.website.updateWebsite.useMutation({
onSuccess: async () => {
await utils.website.getWebsites.invalidate();
},
});
const utils = trpc.useContext();
const websites = trpc.website.getWebsites.useQuery(undefined, {
enabled: isAuthenticated,
});
const updateWebsite = trpc.website.updateWebsite.useMutation({
onSuccess: async () => {
await utils.website.getWebsites.invalidate();
},
});
No description
1 Reply
Typedef
Typedef14mo ago
Fixed: Another context was conflicting with TRPC because both uses react-query.
Want results from more Discord servers?
Add your server