我想使用react设置Firebase Auth预制UI 我从github复制了代码 我收到此错误:
TypeError:firebase__WEBPACK_IMPORTED_MODULE_2 ___ default.a.auth未定义
https://github.com/firebase/firebaseui-web-react
im使用VScode和node.js安装软件包
import React from 'react';
import StyledFirebaseAuth from 'react-firebaseui/StyledFirebaseAuth';
import firebase from 'firebase';
uiConfig = {
// Popup signin flow rather than redirect flow.
signInFlow: 'popup',
// We will display Google and Facebook as auth providers.
signInOptions: [
firebase.auth.GoogleAuthProvider.PROVIDER_ID,
firebase.auth.FacebookAuthProvider.PROVIDER_ID
],
callbacks: {
// Avoid redirects after sign-in.
signInSuccessWithAuthResult: () => false
}
};
答案 0 :(得分:0)
尝试同时导入Firebase和要使用的特定软件包。我在应用程序中使用“ auth”包遇到了同样的问题,但是在通用导入后专门添加了它,使事情正常了:
import * as firebase from "firebase/app";
import "firebase/auth";
您可以在official documentation中进行检查。