invalidate vs refetch
Say this post in twitter
1: is it safe to use
refetch this way when available ?
2: and bring the whole const queryClient = useQueryClient() only when invalidating queries not available in the current components?
3: which bring me to another question that is the difference between queryClient.refetchQueriesand queryClient.invalidateQueries?
1 Reply
passive-yellow•4w ago
1 & 2. i suppose it won't cause problems in this case, i assume
refetch doesn't change between re-renders
3.
- refetch forces the fetch in the moment of calling it
- invalidating refetches only when some component uses it
- in that case there would be no difference since TanStackQueryDemo uses the query