4
votes

I'm trying to use the firebase in a react native project

I installed the firebase in my project:

npm install --save firebase

and I'm importing it into my app.js

import firebase from 'firebase';
import React, { Component } from 'react';
import {
  Platform,
  Text,
  View
} from 'react-native';

type Props = {};
export default class App extends Component<Props> {

  render() {
    return (
      <View >
        <Text>Testando Firebase</Text>    
      </View>
    );
  }
}

and then the error is displayed:

Objects are not valida as a react child (found: object with keys{&&typeof, type, key, ref, props, _owner, _store}). If you meant to render a collection of children, use an array instead.

but when I remove the import from firebase, the app works perfectly.

2
It's weird, I try it in expo snack.expo.io/r1tb9Mhlm and no error. By the way, to use firebase you need add some more firebase config for your app - tuan.tran
Your import is wrong, it should be import firebase from 'firebase'. However, the error message doesn't seem to be related to it. If changing the import doesn't solve the issue, we can check for further errors - soutot
Apparently this is all right but it does not work, so I removed the firebase and installed a previous version npm install --save [email protected], now works perfectly - Bruno Aparecido da Silva
I would appreciate that if you accept the answer! - MohamadKh75

2 Answers

6
votes

Try to install the version 5.0.2. Use this command as administrator:

npm uninstall firebase    
npm install --save [email protected]

As far as i see, the current version (5.0.4) is buggy!

0
votes

You need to import as follow

import * as firebase from 'firebase';

You first must have firebase installed.