Firebase “\u auth.default.auth”不是一个函数

Firebase “\u auth.default.auth”不是一个函数,firebase,react-native,visual-studio-code,react-native-android,Firebase,React Native,Visual Studio Code,React Native Android,我已经安装了react native和firebase的最新版本。当我试图用Email和PasswordEmail调用firebase.auth.signand RetrieveData时,password出现了一个错误,并表示_auth.default.auth不是一个函数 在根文件夹文件中未获取此类错误。它起作用了。但我正在进入文件夹文件并调用fire base函数,这将发生错误 根文件夹文件App.js firebase.auth.signandRetrieveDatawithEmaila

我已经安装了react native和firebase的最新版本。当我试图用Email和PasswordEmail调用firebase.auth.signand RetrieveData时,password出现了一个错误,并表示_auth.default.auth不是一个函数

在根文件夹文件中未获取此类错误。它起作用了。但我正在进入文件夹文件并调用fire base函数,这将发生错误

根文件夹文件App.js

firebase.auth.signandRetrieveDatawithEmailandPasswordEmail,password

工作

./src/component/LoginForm.js

firebase.auth.signandRetrieveDatawithEmailandPasswordEmail,password

不工作。获得上述错误

---------带有firebase.auth.onAuthStateChangeduser的App.js根级工作代码----------

import React, { Component } from 'react';
import { View } from 'react-native';
import { Header, Button, Spinner } from './components/common';
import LoginForm from './components/LoginForm';
import firebase from '@firebase/app';

class App extends Component {
  state = { loggedIn: false };

  componentWillMount() {

    var config = {
      apiKey: 'xxxxxxxxxxxxxxx-MY',
      authDomain: 'xxxx-a115e.firebaseapp.com',
      databaseURL: 'https://xxxx-xxxx.firebaseio.com',
      projectId: 'xxx-xx',
      storageBucket: 'xxxx-a115e.appspot.com',
      messagingSenderId: 'xxxxxxxxx'
    };
    firebase.initializeApp(config);

    firebase.auth().onAuthStateChanged((user) => {
      if(user) {
        this.setState({ loggedIn: true });
      }else {
        this.setState({ loggedIn: false });
      }
    }); 

   }
-------/src/components/LoginForm.js文件不工作firebase.auth.signand使用EmailAndPassword检索数据--------


我发现这种情况是因为文件不在项目文件结构的根级别。请帮助我获取此解决方案。

新的firebase API必须像这样为Auth使用导入

import firebase from 'firebase/app';
import 'firebase/auth';

我使用的是firebase 5.11.0版。希望这有帮助:

新的firebase API必须像这样为Auth使用导入

import firebase from 'firebase/app';
import 'firebase/auth';

我使用的是firebase 5.11.0版。希望这对您有所帮助:

您在Firebase中使用哪个库?npm安装Firebase-保存和npm安装Firebase管理-保存我安装的两个库。。当前可用版本。。最新的情况发生在Android Emulator上..您使用哪个库用于Firebase?npm安装Firebase-保存和npm安装Firebase管理-保存我安装的两个。。当前可用版本。。最新的情况发生在Android Emulator上。。