TanStackT
TanStack5mo ago
11 replies
uniform-turquoise

invalidateQueries not triggering refetch consistently across projects

Hello,

I’m running into an issue with invalidateQueries. I’m using the same setup in two different projects, and in one project it works as expected, while in the other it doesn’t trigger a refetch after invalidation.

Here’s my setup:

// Hook
const useGetMe = () => {
  return useQuery({
    queryKey: ["get-me"],
    queryFn: getMe,
    retry: 0,
    refetchOnMount: false,
    refetchInterval: false,
  });
};

// In component
await queryClient.invalidateQueries({ queryKey: ["get-me"] });


In the first project, invalidateQueries correctly triggers a refetch.
In the second project, not working even i'm using the same code.

I don’t understand why the behavior differs between the two projects when the code is essentially the same. Could this be related to how refetchOnMount and invalidation interact, or maybe a config difference I’m overlooking?

Thanks for your help!
Was this page helpful?