FirebaseExtended / reactfire

Hooks, Context Providers, and Components that make it easy to interact with Firebase.
https://firebaseopensource.com/projects/firebaseextended/reactfire/
MIT License
3.51k stars 399 forks source link

Remove `useUser`'s `initialData` override #539

Closed jhuleatt closed 2 years ago

jhuleatt commented 2 years ago

Description

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

https://github.com/FirebaseExtended/reactfire/blob/414201e88bd6f6701998993f6203e4d49773147b/src/auth.tsx#L29-L33

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.