React query Refetching on page change
I am using this code ( react query + trpc) , i want whenever i change links , router , the query should rerun and new data should come from the database but it is not happening , i tried various refetching methods but none of them worked , anyone who can suggest something
1 Reply
what you're probably looking for is query invalidation https://tanstack.com/query/v4/docs/react/guides/query-invalidation
you can also use the
refetchOnMount: "always"
so it will force a refetch on mount even if data is not stale (not marked as invalid)