我正在尝试在我的react-native应用程序中使用firestore,但是当我添加firebase.firestore()。collection()时,出现此错误
我发现搜索的任何解决方案都不适合我
我的课:
import firebase from '../backend/Connection2';
componentDidMount(){
this.test();
}
test(){
firebase.firestore().collection('pause').doc('pause').set({
name: 'San Francisco', state: 'CA', country: 'USA',
capital: false, population: 860000
});
}
Connection2:
import * as firebase from 'firebase';
import firestore from 'firebase/firestore'
const settings = {};
const config = {
apiKey: "lorem ipsum",
authDomain: "lorem ipsum",
databaseURL: "lorem ipsum",
projectId: "lorem ipsum",
storageBucket: "lorem ipsum",
messagingSenderId: "lorem ipsum",
appId: "lorem ipsum"
};
firebase.initializeApp(config);
firebase.firestore().settings(settings);
export default firebase;
Package.json:
{
"name": "jdp_android",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
"@firebase/app": "^0.4.5",
"@firebase/app-types": "^0.4.0",
"@firebase/firestore": "^1.4.0",
"@firebase/messaging": "^0.3.22",
"@react-native-community/netinfo": "^3.2.1",
"@react-native-firebase/app": "^0.0.4",
"firebase": "^6.0.4",
"global": "^4.3.2",
"moment": "^2.24.0",
"moment-timezone": "^0.5.25",
"opencollective-postinstall": "^2.0.2",
"prop-types": "^15.7.2",
"react": "16.8.3",
"react-native": "0.59.9",
"react-native-firebase": "^5.4.3",
"react-native-gesture-handler": "^1.2.1",
"react-native-stopwatch-timer": "^0.0.20",
"react-navigation": "^3.11.0"
},
"devDependencies": {
"@babel/core": "^7.4.5",
"@babel/runtime": "^7.4.5",
"babel-jest": "^24.8.0",
"jest": "^24.8.0",
"metro-react-native-babel-preset": "^0.54.1",
"react-test-renderer": "16.8.3"
},
"jest": {
"preset": "react-native"
}
}