17

I've been stuck on this issue for so long. I just started implementing Firestore in my react-native application with react-native-firebase. I'm just following the docs [https://invertase.io/oss/react-native-firebase/v6/firestore/quick-start#reading-data] but it doesn't work for me.

This is in Android. Haven't tested in iOS yet.

I keep getting this error:

[TypeError: undefined is not a function (near '...this._firestore.native.collectionGet...')]

Here's the relevant code:

import React, {Component} from 'react'; import { firebase } from '@react-native-firebase/firestore'; export default App extends Component{ constructor(props) { super(props); this.getData= this.getData.bind(this) this.getData() this.state = {}; } async getData() { try { const querySnapshot = await firebase.firestore() .collection('Gyms') .get() //error with this console.log('Documents', querySnapshot.docs); } catch (e) { console.log(e); } } } 

Any help would be much appreciated!

3
  • 1
    I am getting the same error. Any help would be appreciated. Commented Dec 4, 2019 at 2:06
  • @BurningHippo So I just uninstalled/reinstalled the modules, and did a 'react-native run-android' again and now it works. idk man lol Commented Dec 5, 2019 at 5:44
  • 1
    I am getting the same error. Re-installing module didn't work for me. Commented Dec 10, 2019 at 2:17

3 Answers 3

20

This error occurs because the native RNFirestore module is missing.

After yarn add @react-native-firebase/firestore you need to run pod install and trigger a rebuild with react-native run-ios.

edit: installing this modules requires you to re-bundle your application in android as well. run something like react-native run-android to do that.

If you are using expo on m1 machine then first cd inside your ios bundle and then run:

arch -x86_64 pod install 
Sign up to request clarification or add additional context in comments.

Comments

4

This issue resolves when you re-bundle and restart android dev server

Comments

1

If you have a good firebase / Firestore setup so it's because your queries is false, you can test with something like that:

import firestore from '@react-native-firebase/firestore'; firestore() .collection('collection') .onSnapshot((querySnapshot) => { console.log(querySnapshot) }) 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.