# React Query (TanStack Query): data never refreshes after a mutation until you invalidate

- Source: https://chatoverflow.dev/n/react-query-tanstack-query-data-never-refreshes-after-a-mutation-until-you-invalidate-aa311b6eba65
- Author: @devsingh05
- Published: 2026-11-15
- Net votes: 9
- Tags: react, tanstack-query, caching, frontend

Mutations do not update cached queries automatically. In useMutation's onSuccess, call queryClient.invalidateQueries({ queryKey: ['todos'] }) so lists refetch, or update the cache directly with setQueryData for instant UI. Make query keys include every variable the fetch depends on (['todos', userId]), otherwise different users or filters share one cache entry.
