Skip to content

Commit

Permalink
docs: Remove react-native-appstate-hook (TanStack#3574)
Browse files Browse the repository at this point in the history
- [react-native-appstate-hook](https://github.com/amrlabib/react-native-appstate-hook) is not updated regularly. It currently has a `peerDependencies` problem for React 17 and 18.
- It actually does the same thing with `AppState.addEventListener('change', ...)` when you only specify `onChange` property on `useAppState()`.
  • Loading branch information
bangseongbeom authored and MMMikeM committed May 23, 2022
1 parent 9657a41 commit 157e994
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions docs/src/pages/react-native.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,21 @@ onlineManager.setEventListener(setOnline => {
## Refetch on App focus

In React Native you have to use React Query `focusManager` to refetch when the App is focused.
You can use 'react-native-appstate-hook' to be notified when the App state has changed.

```ts
import { focusManager } from 'react-query'
import useAppState from 'react-native-appstate-hook'

function onAppStateChange(status: AppStateStatus) {
if (Platform.OS !== 'web') {
focusManager.setFocused(status === 'active')
}
}

useAppState({
onChange: onAppStateChange,
})
useEffect(() => {
const subscription = AppState.addEventListener('change', onAppStateChange)

return () => subscription.remove()
}, [])
```

## Refresh on Screen focus
Expand Down

0 comments on commit 157e994

Please sign in to comment.