I implemented this into my application but it seems that the code to detect if currentUser exists
!!currentUser ? (
<RouteComponent {...routeProps} />
) : (
<Redirect to={"/login"} />
)
is executed before loading the currentUser
useEffect(() => {
app.auth().onAuthStateChanged(setCurrentUser);
}, []);
so the result is the user will be redirected to login after refreshing the page.
I implemented this into my application but it seems that the code to detect if currentUser exists
is executed before loading the currentUser
so the result is the user will be redirected to login after refreshing the page.