Skip to content

Commit

Permalink
docs(react-query): add example for Expo Network in online status mana…
Browse files Browse the repository at this point in the history
…gement (#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>
  • Loading branch information
3 people authored Nov 22, 2024
1 parent 436422c commit 102b6a8
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions docs/framework/react/react-native.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,19 @@ onlineManager.setEventListener((setOnline) => {
})
```

or

```tsx
import { onlineManager } from '@tanstack/react-query'
import * as Network from 'expo-network'

onlineManager.setEventListener((setOnline) => {
return Network.addNetworkStateListener((state) => {
setOnline(state.isConnected)
})
})
```

## Refetch on App focus

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":
Expand Down

0 comments on commit 102b6a8

Please sign in to comment.