2017-10-13 13 views
2

我跟隨韋斯博react for beginner教程(更新),我堅持認證與firebase。嘗試使用github進行身份驗證。與firebase的身份驗證。 AuthWithOAuthPopup不是函數

得到一個錯誤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; 
+0

如何導入'base'? – Dane

+0

從'../ base'進口基地;' – karolis2017

+0

你能分享那個文件嗎? – Dane

回答

0

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

+1

謝謝,我已經找到了這個'遷移指南',但不知道如何實施它,並改變我目前的狀況。https://github.com/tylermcginnis/re-base/blob/master/ docs/MIGRATION.md – karolis2017

+1

也請參閱此問題:https://github.com/tylermcginnis/re-base/issues/225 – Dane