繁体   English   中英

将 firebase 导入 react-native

[英]importing firebase to 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 中删除导入时,该应用程序运行良好。

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

npm uninstall firebase    
npm install --save firebase@5.0.2

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

您需要按如下方式导入

从'firebase'导入*作为firebase;

您首先必须安装 firebase。

解决方案先生们是卸载当前版本的 firebase 并安装旧版本。 第一步 npm 卸载 firebase

第二步 npm i firebase@8.0.3

这是适用于我的案例的版本,祝你好运!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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