[go: nahoru, domu]

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

Remove useUser's initialData override #539

Merged
merged 3 commits into from
Aug 19, 2022

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 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.

None yet

2 participants