You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Why is the value of isSignedIn changing without me navigating around the page? I thought this might be due to React StrictMode but I have that disabled.
The text was updated successfully, but these errors were encountered:
RylanSchaeffer
changed the title
Clarifying why useAuth() returns different values?
Clarifying why useAuth() returns false, then true, without refreshing?
Jun 14, 2022
I just saw the README says "The hook useAuth might be used to get access to the auth from React component to render (and rerender) the app depending on the current auth state."
Ok I know it's an old discussion but I found a trick to always wait useAuth is finished.
Also as I plan my redirection base on logged because it was first false it was annoying to be redirect to the login page when you refresh your protected page.
const [loading, setLoading] = useState(true);
const [logged, session] = useAuth();
// Handle to not have redirection on refresh
useEffect(() => {
setLoading(false);
}, [logged]);
if (loading) {
return null
}
Hi! I'm using
react-token-auth
and I'm noticing something odd. First, here's my code forcreateAuthProvider
And here's my simple
App()
component:When I access the page,
isSignedIn
is logged as false and then without refreshing the page, is logged again as true:Why is the value of
isSignedIn
changing without me navigating around the page? I thought this might be due to React StrictMode but I have that disabled.The text was updated successfully, but these errors were encountered: