Skip to content

Conversation

jhuleatt
Copy link
Collaborator

Description

useUser currently overrides initialData if auth.currentUser is not undefined:

reactfire/src/auth.tsx

Lines 29 to 33 in 414201e

// only set/override initialData if auth has finished loading
if (auth.currentUser !== undefined) {
_options.initialData = auth.currentUser;
_options.startWithValue = auth.currentUser;
}

The idea was that we might be able to get useUser to load with the correct auth state faster than if we had waited for the underlying useIdTokenResult to finish. This was based on the assumption that auth.currentUser is undefined while the Auth SDK is booting up, null only when the Auth SDK is booted up and a user isn't signed in, and truthy otherwise.

However, this is undocumented behavior, so we shouldn't rely on it.

@jhuleatt jhuleatt requested a review from jamesdaniels August 19, 2022 15:11
@jhuleatt jhuleatt merged commit 9754f86 into main Aug 19, 2022
@jhuleatt jhuleatt deleted the jhuleatt-remove-auth-optimization branch August 19, 2022 16:00
@FirebaseExtended FirebaseExtended locked and limited conversation to collaborators Sep 19, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants