Please provide the following:
- SDK Version: 36
- Platforms(Android/iOS/web/all):all
I found out some documentation in official expo forum about firestore and everything seems to be working. And I were able to implement whole login, sign up flow with various providers from firebase. But I can not run any query from firestore. I am doing it like this:
const[dataSource, setDataSource] = React.useState({});
const getMealTypes = (mealTypes) =>{
const Meals = [];
mealTypes.get().then(function (doc) {
if (doc.exists) {
const {title, count} = doc.data();
Meals.push({
key: doc.id,
title,
count
})
} else {
console.log("No such document!");
}
}).catch(function (error) {
console.log("Error getting document:", error);
});
console.log(Meals);
setDataSource(Meals);
}
React.useEffect(() => {
if (!firebase.apps.length) {
firebase.initializeApp(firebaseConfig);
}
const mealTypes = firebase.firestore().collection('mealTypes');
getMealTypes(mealTypes);
setDataSource([]);
}, []);
I have tried many more ways to get that response, but it never go into promise after get() function. Is get() broken in expo or am I doing something wrong?