Skip to content

Commit df80cc8

Browse files
docs: Remove react-native-appstate-hook (#3574)
- [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()`.
1 parent 07c9ce0 commit df80cc8

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

docs/src/pages/react-native.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,21 +28,21 @@ onlineManager.setEventListener(setOnline => {
2828
## Refetch on App focus
2929

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

3332
```ts
3433
import { focusManager } from 'react-query'
35-
import useAppState from 'react-native-appstate-hook'
3634

3735
function onAppStateChange(status: AppStateStatus) {
3836
if (Platform.OS !== 'web') {
3937
focusManager.setFocused(status === 'active')
4038
}
4139
}
4240

43-
useAppState({
44-
onChange: onAppStateChange,
45-
})
41+
useEffect(() => {
42+
const subscription = AppState.addEventListener('change', onAppStateChange)
43+
44+
return () => subscription.remove()
45+
}, [])
4646
```
4747

4848
## Refresh on Screen focus

0 commit comments

Comments
 (0)