react-firebase-hooks icon indicating copy to clipboard operation
react-firebase-hooks copied to clipboard

user in useAuthState return undefined on refresh

Open Progressive-Programmer opened this issue 2 years ago • 0 comments

"firebase": "^10.3.1",
"next": "13.4.13",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-firebase-hooks": "^5.1.1",

The user is signed in using useSignInWithGoogle

const [signInWithGoogle, loading, error] = useSignInWithGoogle(auth);

Here's the sample code

` const [user, loading, error] = useAuthState(auth); const router = useRouter()

useEffect(()=>{
if (!user){ console.log(user) router.push('/login') } },[user])

if (loading) { <Backdrop isOpen={loading} /> } return ( children )`

Progressive-Programmer avatar Oct 12 '23 08:10 Progressive-Programmer