Skip to content

Instantly share code, notes, and snippets.

@josefrichter josefrichter/index.jsx
Last active Dec 21, 2015

Embed
What would you like to do?
class Application extends React.Component {
constructor() {
super();
this.state = {
currentUser: null,
joinError: null,
};
}
componentWillMount() {
var _this = this; // TODO can be avoided?
/**
* onAuth fires anytime the auth status of this user changes
*/
_fbBase.onAuth((authData) => {
if (!authData) {
// console.log('unauthenticated user');
this.setState({
user: null,
});
return;
}
console.log('authData', authData);
var newUserID = authData.facebook.id;
// save new user to database
var newUser = _fbUsers.child(newUserID).update(authData, (error) => { // the fat arrouw here should do the trick?
if (error) {
alert("Data could not be saved." + error);
} else {
console.log("Data saved successfully.", this);
this.setState({currentUser: authData}); // TODO can be avoided?
}
});
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.