diff --git a/src/utils/context/LoginContextProvider.tsx b/src/utils/context/LoginContextProvider.tsx index 1c5d418..fa68baa 100644 --- a/src/utils/context/LoginContextProvider.tsx +++ b/src/utils/context/LoginContextProvider.tsx @@ -19,6 +19,9 @@ export const LoginContextProvider: FunctionComponent = (props): JSX.Element => { initialLoginState = LoginState.LoggedIn; } + const [loginState, setLoginState] = useState(initialLoginState); + const [permission, setPermission] = useState(initialUserPerm); + useEffect(() => { // this is the first api call so if it fails we know there is no connection to backend callAPI( @@ -45,10 +48,7 @@ export const LoginContextProvider: FunctionComponent = (props): JSX.Element => { setLoginState(LoginState.LoggedOut); } ); - }, [features]); - - const [loginState, setLoginState] = useState(initialLoginState); - const [permission, setPermission] = useState(initialUserPerm); + }, [features, loginState]); const hist = useHistory(); const loc = useLocation();