I am using firebase web SDK, as my project is still on expo
I can't seem to add or get any results from firestore. No error is thrown, nothing is shown, nothing is saved also.
import * as firebase from 'firebase'
import firestore from 'firebase/firestore'
var config = {
apiKey: "xxxxxxxxxxxxxxxxxx",
authDomain: "xxxxxxxxxxxxxxxxxx",
databaseURL: "xxxxxxxxxxxxxxxxxx",
projectId: "xxxxxxxxxxxxxxxxxx",
storageBucket: "xxxxxxxxxxxxxxxxxx",
messagingSenderId: "xxxxxxxxxxxxxxxxxx"
};
firebase.initializeApp(config);
var db = firebase.firestore();
var docRef = db.collection('users').doc('alovelace');
var setAda = docRef.set({
first: 'Ada',
last: 'Lovelace',
born: 1815
})
anyone having the same issue? someone knows how to fix it?
I found a solution that is compatible with Expo just run:
npm i -S firebase @firebase/firestore
and add to your code
import * as firebase from 'firebase';
import '@firebase/firestore';
now you can use
firebase.firestore()
Hope it helps!
Try to use react-native-firebase, it is the officially recommended React Native library for Cloud Firestore.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With