我是适合新的Firebase SDK的应用程序。它编译没问题,但是当我通过控制台收到错误消息,表明stats onAuth不是函数时,应用不会显示
我已经在这里完成升级过程:https://firebase.google.com/support/guides/firebase-web
似乎无法使其正常工作
'use strict';
import Reflux from 'reflux';
import update from 'react-addons-update';
import Actions from '../actions/Actions';
require('firebase/auth');
require('firebase/database');
require('firebase/firestore');
var config = {
apiKey: 'XXXXX',
authDomain: 'XXXXXX',
databaseURL: 'XXXXXX'
};
firebase.initializeApp(config);
const baseRef = firebase.database().ref();
const usersRef = baseRef.child('users');
const defaultUser = {
uid: '',
username: '',
upvoted: null,
submitted: null,
isLoggedIn: false,
md5hash: null,
latestPost: null
};
let currentUser = Object.assign({}, defaultUser);
const UserStore = Reflux.createStore({
listenables: Actions,
init() {
// triggered by auth changes
baseRef.onAuth((authData) => {
if (!authData) {
// user is logged out
usersRef.off();
this.logoutCompleted();
} else {
// user is logged in
this.loginCompleted(authData.uid);
}
});
},
logout() {
baseRef.unauth();
},
答案 0 :(得分:0)
baseRef
是引用类型对象:
const baseRef = firebase.database().ref();
从API文档中可以看到,Reference没有名为onAuth
或unauth
的方法。不知道您要在这里做什么,但是显然没有遵循已记录的API。