【问题标题】:Auth with firebase. AuthWithOAuthPopup is not a function使用 Firebase 进行身份验证。 AuthWithOAuthPopup 不是函数
【发布时间】:2017-10-13 05:21:10
【问题描述】:

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

收到错误TypeError: __WEBPACK_IMPORTED_MODULE_3__base__.a.AuthWithOAuthPopup is not a function

我的代码好像和教程里的一样:

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;

【问题讨论】:

  • 你是如何导入base 的?
  • import base from '../base';
  • 你也可以分享那个文件吗?
  • 刚刚用 base.js 更新了我的帖子
  • 看起来 authWithOAuthPopup 已被弃用:github.com/tylermcginnis/…

标签: reactjs firebase firebase-authentication


【解决方案1】:

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

【讨论】:

猜你喜欢
  • 2021-11-14
  • 1970-01-01
  • 2020-10-09
  • 2017-03-11
  • 2018-10-19
  • 2021-05-26
  • 2017-09-12
  • 2021-07-20
  • 1970-01-01
相关资源
最近更新 更多