简体   繁体   English

React Native Firebase 未定义

[英]React Native firebase is undefined

Hi I keep getting this error when trying to run my react-native app on expo go on my phone嗨,我在手机上尝试在 expo go 上运行我的 react-native 应用程序时不断收到此错误

TypeError: undefined is not an object (evaluating '_app.default.apps') and the error shows it pointing to the firebase variable on line 19 in the code below in the if statement where it says firebase: TypeError: undefined is not an object (evaluating '_app.default.apps') 错误显示它指向下面代码中第 19 行的 firebase 变量,在 if 语句中它说的是 firebase:


import firebase from 'firebase/app';
require('firebase/auth');
import Constants from 'expo-constants';


// Initialize Firebase
const firebaseConfig = {
  apiKey: Constants.manifest.extra.apiKey,
  authDomain: Constants.manifest.extra.authDomain,
  projectId: Constants.manifest.extra.projectId,
  storageBucket: Constants.manifest.extra.storageBucket,
  messagingSenderId: Constants.manifest.extra.messagingSenderId,
  appId: Constants.manifest.extra.appId,
  measurementId: Constants.manifest.extra.measurementId
};

let Firebase;

if (firebase.apps.length === 0) {
  Firebase = firebase.initializeApp(firebaseConfig);
}

export default Firebase;

this in turn is causing I believe an Invariant violation as well.这反过来又导致我相信不变量违反。

Any help please?请问有什么帮助吗?

FirebaseSDK changed their API in the new version 9 so now import firebase from “firebase/app” won't work FirebaseSDK 在新版本 9 中更改了他们的 API,因此现在import firebase from “firebase/app”将不起作用

You need to use the import { initializeApp } from 'firebase/app';您需要使用import { initializeApp } from 'firebase/app'; to initiate your app or import from firebase/compat/app to use the old API启动您的应用程序或从 firebase/compat/app 导入以使用旧 API

Refer to https://firebase.google.com/docs/web/modular-upgrade for more about the changes and https://firebase.google.com/docs/web/setup for the new API请参阅https://firebase.google.com/docs/web/modular-upgrade了更多的变化, https://firebase.google.com/docs/web/setup新API

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 未定义不是对象React Native和Firebase - Undefined is not an object React Native and Firebase React Native w/ firebase “未定义不是对象” - React Native w/ firebase “undefined is not an object” React Native Firebase undefined 不是 object(评估 'this.storage.setItem') - React Native Firebase undefined is not an object (evaluating 'this.storage.setItem') 从firebase查询单个值,React Native-Error,未定义 - Query single value from firebase, React Native-Error, undefined 解构 object 反应来自 firebase 的本机钩子返回未定义 - Destructuring object react native hooks from firebase returns undefined undefined 不是 object(评估'auth.tenanatId')在 firebase react native - undefined is not an object (evaluating 'auth.tenanatId') in firebase react native Expo Camera Photo Upload To Firebase Storage 未定义 - React Native - Expo Camera Photo Upload To Firebase Storage is undefined - React Native Firebase 在 React Native 数据获取中返回“未定义”值 - Firebase returning "undefined" value in React Native data fetch listRef.listAll() 函数未定义(react-native-firebase) - listRef.listAll() function is undefined (react-native-firebase) 无法读取未定义 React-Native Firebase React-native-fetch-blob 的属性“DocumentDir” - Cannot read property 'DocumentDir' of undefined React-Native Firebase React-native-fetch-blob
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM