简体   繁体   中英

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.

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

npm uninstall firebase    
npm install --save firebase@5.0.2

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

You need to import as follow

import * as firebase from 'firebase';

You first must have firebase installed.

The solution gentlemen is to uninstall the current version of firebase and install an older version. 1st step npm uninstall firebase

2nd step npm i firebase@8.0.3

It was the version that worked for my case, good luck that force is with you!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM