2
votes

I've been trying to integrate Firebase into my react native app.

I created my RN project using react-native init myProjectName and cd ios && pod install

I've followed the installation guide from https://rnfirebase.io/. after finish setup Firebase by yarn add @react-native-firebase/app and all other steps, I tried to integrate Firebase Cloud Firestore and followed this doc https://rnfirebase.io/firestore/usage , but then i got TypeError: undefined is not a function near (...'this.firestore.native.collectionGet...') error.

Here are the dependencies in package.json

"dependencies": {
    "@react-native-firebase/app": "^7.2.0",
    "@react-native-firebase/firestore": "^7.2.0",
    "react": "16.11.0",
    "react-native": "0.62.2"
  },

Here are the codes in App.js

import React, {useEffect} from 'react';
import {SafeAreaView, View, Text, StatusBar} from 'react-native';
import firebase from '@react-native-firebase/app';
import firestore from '@react-native-firebase/firestore';

const App = () => {
  const getData = async () => {
    const db = await firestore().collection('stories').get();

    console.log({db});
  };

  useEffect(() => {
    getData();
  });

  return (
    <>
      <StatusBar />
      <SafeAreaView>
        <View>
          <Text>Hello There</Text>
        </View>
      </SafeAreaView>
    </>
  );
};

export default App;

Here's are the screenshots of my projects:

Error

Firestore

1

1 Answers

0
votes

I would highly recommend checking a similar issue on github[1].

It seems what may have resolved the issue for the user was to guarantee that the native module was properly installed.

[1]https://github.com/invertase/react-native-firebase/issues/3749