From 2962629a452ac1e643b6558afabe33f48f636925 Mon Sep 17 00:00:00 2001 From: ttlong3103 Date: Wed, 24 Jun 2020 16:47:02 +0700 Subject: [PATCH] Fix bug in example of functional component I found out that when _handleAppStateChange is triggered, appState is still "active". Therefore, ```appState.match(/inactive|background/)``` always return null. I believe this because _handleAppStateChange passed to useEffect was not updated. I propose a fix that is to add _handleAppStateChange to dependencies list of useEffect. --- docs/appstate.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/appstate.md b/docs/appstate.md index 740a7ba0a84..c22729798d8 100644 --- a/docs/appstate.md +++ b/docs/appstate.md @@ -48,7 +48,7 @@ const AppStateExample = () => { return () => { AppState.removeEventListener("change", _handleAppStateChange); }; - }, []); + }, [_handleAppStateChange]); const _handleAppStateChange = (nextAppState) => { if (appState.current.match(/inactive|background/) && nextAppState === "active") {