Firebase 抛出错误:';undefined不是按钮按';时的函数(计算';(app.default.auth()';));

Firebase 抛出错误:';undefined不是按钮按';时的函数(计算';(app.default.auth()';));,firebase,react-native,firebase-authentication,Firebase,React Native,Firebase Authentication,我遇到了firebase的问题。我修复了第一个错误,将导入更改为从“@firebase/app”导入firebase,正如所建议的那样,(之前是从“firebase”导入firebase)。现在我遇到了另一个问题,我刚刚开始学习react native,所以我已经用尽了所有的选择 初始化工作 componentWillMount() { firebase.initializeApp({ apiKey: 'AIzaSy...3LQ7MI...zexagpf9...80',

我遇到了firebase的问题。我修复了第一个错误,将导入更改为从“@firebase/app”导入firebase,正如所建议的那样,(之前是从“firebase”导入firebase)。现在我遇到了另一个问题,我刚刚开始学习react native,所以我已经用尽了所有的选择

初始化工作

componentWillMount() {
    firebase.initializeApp({
      apiKey: 'AIzaSy...3LQ7MI...zexagpf9...80',
      authDomain: 'authentication-7...d.firebaseapp.com',
      databaseURL: 'https://authentication-7...d.firebaseio.com',
      projectId: 'authentication-7...d',
      storageBucket: 'authentication-7...d.appspot.com',
      messagingSenderId: '1740...445'
    });
}
然后在我的登录组件中,当按下
login
按钮时

onButtonPress() {
    const { email, password } = this.state;
    firebase
      .auth()
      .signInWithEmailAndPassword(email, password)
      .catch(() => {
        firebase
          .auth()
          .createUserWithEmailAndPassword(email, password)
          .catch(() => {
            this.setState({ error: 'Authentication failed: ' + err });
          });
      });
}

<Button onPress={this.onButtonPress.bind(this)}>Login</Button>
也许我正在学习一个过时的教程?

从另一个线程为我修复了它。
undefined is not a function (evaluating '_app.default.auth()')
onButtonPress
    C:\Users\Me\Desktop\react-native_2\auth\src\components\loginForm.js:11:4
proxiedMethod
    C:\Users\Me\Desktop\react-native_2\auth\node_modules\react-proxy\modules\createPrototypeProxy.js:44:35
touchableHandlePress
    C:\Users\Me\Desktop\react-native_2\auth\node_modules\react-native\Libraries\Components\Touchable\TouchableOpacity.js:211:45