fetchQuery result not persisted to localStorage when using a persister #5992
-
I've been migrating old apps for my company from Mobx/Redux to using React Query. Sometimes the migration is too difficult or time-consuming if we choose to use react query as the only source of truth, so we compromise on synching the state to react query via actions (basically using fetchQuery in certain situations instead of useQuery directly). I've been using a localStorage persister to persist the cache to localStorage and I've noticed that query results from fetchQuery calls and not persisted, only results using the useQuery hook. Is this deliberate? Is there any way around this? Thanks in advance |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
This shouldn't be the case. Every successful query in the cache should be persisted, no matter how it got there. Just note that queries that have no active observer (via useQuery) are eligible for garbage collection, so if you've reduced |
Beta Was this translation helpful? Give feedback.
This shouldn't be the case. Every successful query in the cache should be persisted, no matter how it got there. Just note that queries that have no active observer (via useQuery) are eligible for garbage collection, so if you've reduced
cacheTime
, that could explain it. Otherwise please show a reproduction