TanStackT
TanStack3y ago
8 replies
colossal-harlequin

InvalidateQuery does not trigger refetch.

This must be a really noob issue but for some reason I have trouble triggering refetch with invalidateQuery(). I have a grid and a details panel and I would like to reload the details panel when user clicks on a row. User could also edit the info so therefore I'd prefer useQuery instead of just useEffect for this page. But the panel doesn't change until I force the entire view to refetch with window focus refetching. All I have is
        queryClient.invalidateQueries({
            queryKey: ["itemversions"],
            refetchType: "all"
        });

in the row click event and
    const { isLoading, error, data } = useQuery({
        queryKey: ['itemversions'],
        queryFn: () => getItemVersion(itemId, version),
    })

in the details pane.

itemId is a prop and it is correctly set. So what am I missing?
Was this page helpful?