You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: pages/docs/advanced/react-native.en-US.mdx
+61
Original file line number
Diff line number
Diff line change
@@ -96,3 +96,64 @@ import { AppState } from 'react-native'
96
96
```
97
97
98
98
For `initReconnect`, it requires some 3rd party libraries such as [NetInfo](https://github.com/react-native-netinfo/react-native-netinfo) to subscribe to the network status. The implementation will be similar to the example above: receiving a `callback` function and trigger it when the network recovers from offline, so SWR can start a revalidation to keep your data up-to-date.
99
+
100
+
101
+
### AsyncStorage Based Persistent Cache
102
+
103
+
You might want to sync your cache to `asyncStorage`. Here's an example implementation:
104
+
105
+
```jsx
106
+
constuseAsyncStorage= () => {
107
+
const [cache, setCache] =useState(null)
108
+
109
+
useLayoutEffect(() => {
110
+
// When initializing, we restore the data from `AsyncStorage` into a map.
0 commit comments