Replies: 1 comment
-
You could throw the data from AsyncStorage, that way SWR will keep retrying but your will get the data as the error. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm handling offline capabilities and using AsyncStorage for most of my data.
I've modified https://gist.github.com/derindutz/179990f266e25306601dd53b8fbd8c6a to store SWR in the AsyncStorage successfully.
However, when app is offline, I want SWR to load from cache instead so there are 2 methods I can think of so far
Method 1, return cache in catch of fetch
However with the above method, the retry capability of SWR is gone since it did not throw any errors.
So my question comes from the 2nd method. I want to load initialData from async storage instead.
so I did..
then in my functional component
However, in the final line, the data and error is forever undefined.
Beta Was this translation helpful? Give feedback.
All reactions