firebaseui-web-react
firebaseui-web-react copied to clipboard
'updateCurrentUser failed: First argument "user" must be an instance of Firebase User or null.' when running in Firebase Hosting
Hi - I'm not sure if this is a bug report for FirebaseUI-web-react of FirebaseUI-web; I suspect this is the correct place but please tell me if not.
I'm running my app in Firebase Hosting, and I'm linking the magic/reserved URLs that autoconfigure firebase (<script src="/__/firebase/init.js"></script>
)
Later, when <StyledFirebaseAuth uiConfig={uiConfig} firebaseAuth={firebase.auth()}/>
is mounted, I get this warn on the console:
Warning: Firebase is already defined in the global scope. Please make sure Firebase library is only loaded once.
This warning is there because window.firebase
is defined (it was defined from in the init.js loaded from the reserved URL).
I understand this is because I have a "version" of firebase loaded from the CDN and another "version" of firebase loaded from NPM (from a firebaseui dependency).
I would ignore this warning (since I made sure I'm loading the same version of Firebase from the CDN and from npm) but after logging in using GOOGLE_AUTH as provider, I get:
updateCurrentUser failed: First argument "user" must be an instance of Firebase User or null. Dismiss
and in my experience this is related to the previous warning.
So, my question would be: what's the correct way to use firebaseui-web-react when I'm running in the Firebase Hosting thus using Firebase from the CDN and not NPM.
thanks
function hack() {
Object.defineProperty((firebase as any).User, Symbol.hasInstance, {
value: (o: any): any => { return o != undefined && o != null; },
configurable: true
});
}
function unhack() {
Object.defineProperty((firebase as any).User, Symbol.hasInstance, {
value: undefined,
configurable: true
});
}
Just do them...
function hack() { Object.defineProperty((firebase as any).User, Symbol.hasInstance, { value: (o: any): any => { return o != undefined && o != null; }, configurable: true }); } function unhack() { Object.defineProperty((firebase as any).User, Symbol.hasInstance, { value: undefined, configurable: true }); }
Just do them...
Where to do this?
I have the same issue...Using nuxt and nuxt/firebase (so using auth in a store) and then using web authui. Interestingly I have almost an identical setup and it is working, so can't work out where is the issue