Skip to content

Commit 102b6a8

Browse files
reichhartdTkDodoautofix-ci[bot]
authored
docs(react-query): add example for Expo Network in online status management (#8298)
* docs: expo-network * ci: apply automated fixes --------- Co-authored-by: Dominik Dorfmeister <[email protected]> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
1 parent 436422c commit 102b6a8

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

docs/framework/react/react-native.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,19 @@ onlineManager.setEventListener((setOnline) => {
2929
})
3030
```
3131

32+
or
33+
34+
```tsx
35+
import { onlineManager } from '@tanstack/react-query'
36+
import * as Network from 'expo-network'
37+
38+
onlineManager.setEventListener((setOnline) => {
39+
return Network.addNetworkStateListener((state) => {
40+
setOnline(state.isConnected)
41+
})
42+
})
43+
```
44+
3245
## Refetch on App focus
3346

3447
Instead of event listeners on `window`, React Native provides focus information through the [`AppState` module](https://reactnative.dev/docs/appstate#app-states). You can use the `AppState` "change" event to trigger an update when the app state changes to "active":

0 commit comments

Comments
 (0)