TanStackT
TanStack17mo ago
1 reply
progressive-amaranth

l Query Revalidation Completes After Mutation

Hey! I've globally set up my MutationCache like this:

mutationCache: new MutationCache({
  onSuccess: (data) => {
    if ('message' in data) {
      toast.success(data.message);
      queryClient.invalidateQueries();
    }
  }
});


Now, in another component, I have an edit form that triggers a mutation inside a popup. The issue is that the popup closes immediately after the mutation, but revalidating (with invalidateQueries) takes some time before the list gets updated.

Do you know if there's any way I can check if queryClient.invalidateQueries(); is still in progress? I’d like to prevent the popup from closing until revalidation is complete.

Thanks!
Was this page helpful?