首页 > 解决方案 > 将 firebase 导入到 react-native

问题描述

我正在尝试在反应原生项目中使用 firebase

我在我的项目中安装了firebase:

npm install --save firebase

我将它导入我的 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>
    );
  }
}

然后显示错误:

对象不能作为反应子项进行验证(找到:带有键{&&typeof、type、key、ref、props、_owner、_store}的对象)。如果您打算渲染一组子项,请改用数组。

但是当我从 firebase 中删除导入时,该应用程序运行良好。

标签: firebasereact-nativefirebase-realtime-database

解决方案


尝试安装 5.0.2 版本。以管理员身份使用此命令:

npm uninstall firebase    
npm install --save firebase@5.0.2

据我所知,当前版本(5.0.4)有问题!


推荐阅读