Is firebase firestore working in expo?

Please provide the following:

  1. SDK Version: 36
  2. 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?

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.