From 157e994c140e2f9b2df5a062a4942bca49660cb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=B0=A9=EC=84=B1=EB=B2=94=20=28Bang=20Seongbeom=29?= Date: Mon, 2 May 2022 04:23:02 +0900 Subject: [PATCH] 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()`. --- docs/src/pages/react-native.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/src/pages/react-native.md b/docs/src/pages/react-native.md index ce814c4c74..a0358c0621 100644 --- a/docs/src/pages/react-native.md +++ b/docs/src/pages/react-native.md @@ -28,11 +28,9 @@ 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') { @@ -40,9 +38,11 @@ function onAppStateChange(status: AppStateStatus) { } } -useAppState({ - onChange: onAppStateChange, -}) +useEffect(() => { + const subscription = AppState.addEventListener('change', onAppStateChange) + + return () => subscription.remove() +}, []) ``` ## Refresh on Screen focus