简体   繁体   English

app.default.firebase 不是 function 错误

[英]app.default.firebase is not a function error

I am trying to create a React Native Android app that connects to a Firebase database and getting an error when I get to "let cloud = firebase.database();"我正在尝试创建一个 React Native Android 应用程序,该应用程序连接到 Firebase 数据库,当我到达“let cloud = firebase.database(); to retrieve the data.检索数据。

import { Container, Header, Title, Content, Body, Text, Button, View, H3, Table, Row, Col } from 'native-base';
import React from "react";
import 'firebase/firestore';
import 'firebase/auth';

import firebase from "firebase/app";

const FirebaseConfig = {
    apiKey: "xxx",
    appId: "xxx",
    projectId: "xxx",
    authDomain: "xxx",
    databaseURL: "xxx",
    storageBucket: "xxx",
    messagingSenderId: "xxx",
  }
      
export default class Chat extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      people: [], 
      }        
  }

  async initializeFirebase(){
    if (firebase.apps.length) {
        await firebase.app().delete();
    }
    firebase.initializeApp(FirebaseConfig);
    
  }

  async componentDidMount(){
    this.initializeFirebase();
    let cloud = firebase.database();
    
  }

  render() {
    return <Container>
      <Content>
        <Body>
            <Text>Testing</Text>
            <Text>{this.state.people.length}</Text>
        </Body>
      </Content>
    </Container>;
  }
}

I'm getting the [Unhandled promise rejection: TypeError: _app.default.database is not a function.我收到 [Unhandled promise 拒绝:TypeError: _app.default.database is not a function。 (In '_app.default.database()', '_app.default.database' is undefined)] error. (在 '_app.default.database()' 中,'_app.default.database' 未定义)] 错误。 How do I solve this?我该如何解决这个问题?

You need to import firebase/database :您需要导入firebase/database

import 'firebase/database";

暂无
暂无

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

相关问题 firebase function、Firebase 中的错误:没有创建 Z035489FF8D092741943E4A89 应用程序'DEFA'2 - error in firebase function, Firebase: No Firebase App '[DEFAULT]' has been created VueJS Firebase app导出默认错误的问题 - VueJS Firebase app problem of export default error 我一直遇到这个错误: Uncaught TypeError: firebase_compat_app__WEBPACK_IMPORTED_MODULE_0__.default.auth is not a function - I keep running into this error: Uncaught TypeError: firebase_compat_app__WEBPACK_IMPORTED_MODULE_0__.default.auth is not a function 最新 @angular/fire 中的错误:Firebase:没有创建 Firebase 应用程序“[DEFAULT]” - 调用 Firebase App.initializeApp() - Error in latest @angular/fire: Firebase: No Firebase App '[DEFAULT]' has been created - call Firebase App.initializeApp() 类型错误:_app.default.auth 不是 function - React Native Web - Firebase - TypeError: _app.default.auth is not a function - React Native Web - Firebase 类型错误:firebase_app__WEBPACK_IMPORTED_MODULE_0___default.a.analytics 不是 function - TypeError: firebase_app__WEBPACK_IMPORTED_MODULE_0___default.a.analytics is not a function app.auth 不是 firebase 反应中的 function 错误 - app.auth is not a function error in firebase react 错误:app.database 不是使用 Firebase 的 function - Error: app.database is not a function using Firebase 错误:没有 Firebase 应用程序“[DEFAULT]”已创建 - 调用 Firebase App.initializeApp() - Error: No Firebase App '[DEFAULT]' has been created - call Firebase App.initializeApp() 是否可以重新初始化默认的 firebase 应用程序? - Is it possible to reinitialize the default firebase app?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM