swr
swr copied to clipboard
In react native, how to use cache to initialize provider?
Bug report
Description / Observed Behavior
I want to achieve the same effect on the web. But my method of getting localstorage is asynchronous. How can I achieve this effect please?
Expected Behavior
https://swr.vercel.app/docs/advanced/cache#localstorage-based-persistent-cache
Repro Steps / Code Example
Additional Context
1.3.0
You could use MMKV if you're willing to install a native library. That uses sync storage persistence with better performance than AsyncStorage. It also works on Web (I added this).
https://github.com/mrousavy/react-native-mmkv
In my library swr-idb-cache:
- Cache provider loads cached data asynchronously
-
After it's ready, the
<SWRConfig value={{ provider }} />
is created