【发布时间】:2021-11-28 07:52:45
【问题描述】:
在我的 React Native 应用程序中,我正在尝试将 Firebase JS SDK 与 this guide 中提到的 Expo 结合使用,尽管在通过 expo install firebase 安装依赖项后,我无法从 firebase/auth 导入模块。调用 getAuth() 等相应方法会导致以下错误:
TypeError: (0, _auth.getAuth) is not a function. (In '(0, _auth.getAuth)()', '(0, _auth.getAuth)' is undefined)
我也无法从firebase/database、firebase/firestore 等导入模块。
我的项目是使用 Typescript 设置的,但我在纯 JS 项目中也遇到了这个问题。
我可以从 firebase/app 导入 firebase,但不能从相应的模块导入:
编辑:我在以下上下文中使用getAuth() 和其他方法:
React.useEffect(() => {
if (response?.type === "success") {
const { id_token } = response.params;
const auth = getAuth();
const provider = new GoogleAuthProvider();
const credential = provider.credential(id_token);
signInWithCredential(auth, credential);
}
}, [response]);
我使用的是 Firebase 8.2.3。
【问题讨论】:
-
你能分享完整的,包括 getAuth() 的使用吗?您还安装了哪个版本的 Firebase?
-
我更新了问题,我使用的是 Firebase 8.2.3
标签: javascript firebase react-native firebase-authentication expo