From cdbf07bde3823c7b6a6ae02e81cff30f3e505c9d Mon Sep 17 00:00:00 2001 From: Marcin Pawlicki <48184525+dynamichny@users.noreply.github.com> Date: Fri, 6 May 2022 12:16:08 +0200 Subject: [PATCH] fix: naming conventions confuse --- dist/index.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/dist/index.js b/dist/index.js index 1200bee..1217256 100644 --- a/dist/index.js +++ b/dist/index.js @@ -3,26 +3,26 @@ import { AppState } from 'react-native'; export default function useAppState(settings) { const { onChange, onForeground, onBackground } = settings || {}; - const [appState, setAppState] = useState(AppState.currentState); + const [currentState, setCurrentState] = useState(AppState.currentState); useEffect(() => { function handleAppStateChange(nextAppState) { - if (nextAppState === 'active' && appState !== 'active') { + if (nextAppState === 'active' && currentState !== 'active') { isValidFunction(onForeground) && onForeground(); - } else if (appState === 'active' && nextAppState.match(/inactive|background/)) { + } else if (currentState === 'active' && nextAppState.match(/inactive|background/)) { isValidFunction(onBackground) && onBackground(); } - setAppState(nextAppState); + setCurrentState(nextAppState); isValidFunction(onChange) && onChange(nextAppState); } - const appState = AppState.addEventListener('change', handleAppStateChange); + const appStateListener = AppState.addEventListener('change', handleAppStateChange); - return () => appState.remove(); - }, [onChange, onForeground, onBackground, appState]); + return () => appStateListener.remove(); + }, [onChange, onForeground, onBackground, currentState]); // settings validation function isValidFunction(func) { return func && typeof func === 'function'; } - return { appState }; + return { appState: currentState }; }