Offline/Persistor network error when device is offline #2477
-
Hello! I'm using the experimental
Thank you for the help! Package versions |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
I got it to work with some custom code, posting it here to share in case anyone else encounters this blocker. onlineManager.setEventListener((setOnline) => {
return NetInfo.addEventListener((state) => {
if (state.isConnected) {
client.setDefaultOptions({
queries: {
cacheTime,
staleTime,
}
});
} else {
// keep cache until back online
client.setDefaultOptions({
queries: {
cacheTime: 'Infinity',
staleTime: 'Infinity',
}
});
}
setOnline(state.isConnected);
});
}); And in my calls to the backend, I check the |
Beta Was this translation helpful? Give feedback.
I got it to work with some custom code, posting it here to share in case anyone else encounters this blocker.
After finding the
onlineManager
while browsing the source code and reading more about it in the docs, here's what I came up with: