importing firebase to react-native

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.

Upvotes: 4

Views: 4112

Answers (3)

Alencar Porto
Alencar Porto

Reputation: 1

The solution is to uninstall the current version of Firebase and install an older version.

1st step npm uninstall firebase

2nd step npm i [email protected]

It was the version that worked for my case.

Upvotes: 0

joko
joko

Reputation: 39

You need to import as follow

import * as firebase from 'firebase';

You first must have firebase installed.

Upvotes: 0

MoKhajavi75
MoKhajavi75

Reputation: 2702

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!

Upvotes: 6

Related Questions