TanStackT
TanStack2y ago
6 replies
popular-magenta

invalidateQueries

Why is the incorrect way of invalidating working and the what I believe is the correct way not?

const result = useQuery({
    queryKey: [WORKOUT_CACHE_KEY, ['/set'], id],
    queryFn: () => getSets(id),
    initialData: [defaultValues],
    staleTime: 1000,
  });

  const queryClient = useQueryClient();

  async function handleDeleteSet(setId: number) {
    await deleteSet(setId);
    //queryClient.invalidateQueries({ queryKey: ['/set'] }); <-- doesn't work
    queryClient.invalidateQueries('/set'); // does work
  }


Also tried a staleTime: 0
Was this page helpful?