I'm an app to fit the new firebase SDK. It compiles not problem but app will not display as I receive an error via console that stats onAuth is not a function
I've been through the upgrade process here: https://firebase.google.com/support/guides/firebase-web
Can't seem to get it to work
'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();
},
baseRef
is a Reference type object:
const baseRef = firebase.database().ref();
As you can see from the API documentation, Reference doesn't have an method called onAuth
or unauth
. Not sure what you're trying to do here, but it's obviously not following the documented API.