'this._firestore.native.x is not a function. react-native-firebase with expo

I'm using expo 44 to develop an app with firebase, to achieve that I'm using the react-native-firebase module that seems to be compatible with expo.

  • I followed the integration guide
  • I installed every required package at the last version available:
"@react-native-firebase/app": "^14.7.0",
"@react-native-firebase/auth": "^14.7.0",
"@react-native-firebase/firestore": "^14.7.0",
  • I added the plugin @react-native-firebase/app into app.json and ran expo prebuild --clean to generate custom code from plugins
  • I then built a development build on eas and deployed it to the iOS simulator (i also tested with android but didn't change anything)

The auth module works fine, which means that the integration with firebase when well but when running any firestore query or any firestore operation i get this error:

this._firestore.native.documentSet is not a function. (In 'this._firestore.native.documentSet(this.path, (0, _serialize.buildNativeMap)(data, this._firestore._settings.ignoreUndefinedProperties), setOptions)', 'this._firestore.native.documentSet' is undefined)

The way I'm importing firestore is by exporting it from this file firestore.ts

import firebase from "@react-native-firebase/app";
import "@react-native-firebase/firestore";

export default firebase.firestore();

This is the code I used to test:

  const signInAnonymously = async () => {
    try {
      const user = await auth.signInAnonymously(); // This works fine
      ...
      await firestore.collection("users").add({ a: "a" }); // Here I get the error
    } catch (error) {
      ...
    }
  };



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source