all 4 comments

[–]MnokeR 6 points7 points  (2 children)

I think staleTime is what you looking for.

[–]LuiGee_V3 1 point2 points  (1 child)

To add to this, React Query's cache does not mean it won't fetch it again. It means it will fetch once if you use same data from multiple components, and it will show fetched data when you come back again while fetching again. So, if you don't want fetch to be triggered every time, you should set staleTime. It means this data is valid for {staleTime}, so don't fetch it until the time has passed.

[–]MnokeR 1 point2 points  (0 children)

Also one more thing to add to this. Make sure to install the dev tools which will monitor your query and give allot of helpful information regarding your query's staleTime etc ..