reactjs - 使用 firebase 进行身份验证。 AuthWithOAuthPopup 不是一个函数

标签 reactjs firebase firebase-authentication

我正在关注 Wes Bos react for Beginner 教程(已更新),但我一直坚持使用 firebase 进行身份验证。尝试使用 github 进行身份验证。

收到错误TypeError:__WEBPACK_IMPORTED_MODULE_3__base__.a.AuthWithOAuthPopup不是函数

我的代码似乎与教程中的相同:

class Inventory extends React.Component {
  constructor() {
    super();
    this.renderInventory = this.renderInventory.bind(this);
    this.renderLogin = this.renderLogin.bind(this);
    this.authenticate = this.authenticate.bind(this);
    this.authHandler = this.authHandler.bind(this);
    this.handleChange = this.handleChange.bind(this);

    this.state = {
      uid: null,
      owner: null
    }
  }

  handleChange(e, key) {
    const fish = this.props.fishes[key];
    const updatedFish = {
      ...fish,
      [e.target.name]: e.target.value
    }
    this.props.updateFish(key, updatedFish);
  }

  authenticate(provider){
    console.log(`trying to login with ${provider}`);
    base.authWithOAuthPopup(provider, this.authHandler);
  }

  authHandler(err, authData) {
    console.log(authData);

  }
  renderLogin() {
    return (
      <div>
        <h1>Log In</h1>
        <button onClick={() => this.authenticate('github')}>Log In with Email</button>
      </div>
    )
  }

这是我的 base.js 文件的样子:

import Rebase from 're-base';
import firebase from 'firebase';

const config = {
   KEYS
};

const app = firebase.initializeApp(config)
const base = Rebase.createClass(app.database())

export default base;

最佳答案

最新版本的 Rebase 中已弃用 authWithOAuthPopup。您可以改用 signInWithEmailAndPassword。请参阅https://firebase.google.com/docs/reference/js/firebase.auth.Auth#signInWithEmailAndPassword

关于reactjs - 使用 firebase 进行身份验证。 AuthWithOAuthPopup 不是一个函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46723008/

相关文章:

java - 不将自定义java对象保存在android studio的firebase中

javascript - 标题必须有内容,并且内容必须可由屏幕阅读器访问

javascript - React-router-dom 不呈现在 switch 中的自定义组件之后定义的路由

firebase - 我正确使用 ForEach 吗?

android - Firebase 获取所有 key

reactjs - React Uncaught TypeError : this. state.messages.map 不是一个函数

android - 错误 :Failed to resolve: com. google.firebase :firebase-core:11. 0.0

javascript - 在我单击 UI 之前,signInWithPopup Promise 不会执行 .catch。 Angular 和 Firebase

javascript - 即使其中一个 promise 被拒绝,也不要让整个任务失败

json - 为什么从远程AWS S3服务器下载json文件时axios GET错误