Skip to content

setting user on unsubscribe function in useEffect #19

Open
@Yasin-97

Description

@Yasin-97

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 }, [])

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions