LocalStorage is being cleared when I go offline and refresh the browser
This is my setup of PersistQueryClient. Everytime I go offline and refresh the page the data disappeared.
This is the localStorage value when I fetches the data
And here when I go offline and refresh the page
10 Replies
judicial-coral•14mo ago
@Gerald are you getting any error in the console about rehydrating for persistence?
national-goldOP•14mo ago
hi @areeb idont get any error about rehydrating
judicial-coral•14mo ago
@Gerald can you try adding a
cacheTime
property to defaultOptions
> queries
and try again?
national-goldOP•14mo ago
@areeb isn't it gcTime?
judicial-coral•14mo ago
yeah sorry I'm using v4, it should be that in the latest one.
national-goldOP•14mo ago
sorry, im using tanstack v5
i already set it to Infinity but still the same
judicial-coral•14mo ago
I'm also having some problems but for Mobile. Can you comment out the
invalidateQueries
part temporarily in onSuccess
and let me know if that fixes it?national-goldOP•14mo ago
@areeb bro you save my life. thank you so much!
judicial-coral•14mo ago
Reason why this was happening: upon refresh, the cache data was rehydrated properly. As soon as that was done, tanstack query carried out paused mutations (if any), followed by invalidating the cache which would clear out all the data you had 😁
national-goldOP•14mo ago
yeah @areeb . another issue is when i set the staleTime for example 2 seconds that data are all gone during offline.
and if i set it to Infinity that data is not getting the data from the remote sources