Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setting user on unsubscribe function in useEffect #19

Open
Yasin-97 opened this issue Nov 24, 2021 · 0 comments
Open

setting user on unsubscribe function in useEffect #19

Yasin-97 opened this issue Nov 24, 2021 · 0 comments

Comments

@Yasin-97
Copy link

Yasin-97 commented Nov 24, 2021

I'm kinda struggling to understand this piece of code!
The unsubscribe fn is run on unmount of this component (context/authContext.js), so how the user and loading states are set to be used in other functions in this component?

useEffect(() => { const unsubscribe = auth.onAuthStateChanged(user => { setCurrentUser(user) setLoading(false) }) return unsubscribe }, [])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant