InvalidatateQuery problem
Custom Hooks
I fetch
useUnits in Units page and I used useAddUnitMutation in AddUnit page. So whenever I navigate to AddUnit page the units queryKey is inactive which is expected.
My problem here is that whenever I invalidate the units and navigate back to Units page, the list of units is not updated but it is still the old data.
As of now I used refetchQueries instead of invalidateQueries but I don't know if this is okay or not. Also, I am using NextJS 13 app & tanstack-query v46 Replies
harsh-harlequinOP•3y ago
Provider
Context
Root Layout
foreign-sapphire•3y ago
refetchOnMount: false prevents stale queries to refetch when you navigate between pages (=when the component mounts). So you've opted out of that, which makes it "not work"harsh-harlequinOP•3y ago
Is there a way that I can only refetchOnMount once invalidateQueries triggers?
foreign-sapphire•3y ago
no, that's what
staleTime is for.absent-sapphire•3y ago
You could removeQueries instead of invalidate, right?
harsh-harlequinOP•3y ago
ohh okayy now I get it, thank youu :))