Skip to content

Commit

Permalink
fix: check auth state if auth initialized
Browse files Browse the repository at this point in the history
  • Loading branch information
rutajdash committed Oct 12, 2022
1 parent b34b150 commit f798de1
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions client/src/context/auth/AuthState.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,12 @@ const AuthState = ({ children }) => {
const [firebaseToken, setFirebaseToken] = useState('');

useEffect(() => {
onAuthStateChanged(auth, async (_user) => {
setUser(_user);
if (_user) setFirebaseToken(await getIdToken(_user, false));
});
if (auth) {
onAuthStateChanged(auth, async (_user) => {
setUser(_user);
if (_user) setFirebaseToken(await getIdToken(_user, false));
});
}
}, []);

useEffect(() => {
Expand Down

0 comments on commit f798de1

Please sign in to comment.