Skip to content

Instantly share code, notes, and snippets.

@josefrichter
Last active December 21, 2015 19:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save josefrichter/5e415f77d8f018d1a26e to your computer and use it in GitHub Desktop.
Save josefrichter/5e415f77d8f018d1a26e to your computer and use it in GitHub Desktop.
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