T
TanStack2y ago
solid-orange

Is it possible to skip cache for a hook?

I am try to do something similar to "cache-policy: 'network-only'" that I think existed in the days of apollo Is this possible to achieve with react-query? My case is the following. I have basically a stateful fetcher function that I'm passing to the component. When the component mounts, I want it to always invoke that function so that it gets the new data. And I don't want it to show the data from the previous computation. I cannot pass a unique value to queryKey because the function has no arguments. I tried passing cacheTime: 0 but it leads to infinite calls to the queryFn.
1 Reply
like-gold
like-gold2y ago
set refetchOnMount:'always' and only show data if isFetchedAfterMount is true

Did you find this page helpful?