我刚刚开始学习React Native,在youtube上观看视频时,遇到了一个我不明白的错误。我认为我的错误是由 firebase.js 文件引起的。`
firebase.js
import * as firebase from "firebase"
import "firebase/firestore"
import "firebase/auth"
const firebaseConfig = {
apiKey: "",
authDomain: "",
projectId: "",
storageBucket: "",
messagingSenderId: "",
appId: ""
};
let app
if (firebase.apps.length === 0){
const firebaseApp = firebase.initializeApp(firebaseConfig)
} else {
app = firebase.app()
}
const db = app.firestore()
const auth = firebase.auth()
export { db, auth }
Run Code Online (Sandbox Code Playgroud)
错误
TypeError: undefined is not an object (evaluating 'app.firestore')
at node_modules\react-native\Libraries\LogBox\LogBox.js:148:8 in registerError
at node_modules\react-native\Libraries\LogBox\LogBox.js:59:8 in errorImpl
at …Run Code Online (Sandbox Code Playgroud)