I'm having an interesting issue, that I don't seem to understand. I must be overlooking some glaring issue. I'm trying to set the state after checking if the user is logged in, so I decided to implement a callback function. However, it doesn't look like my callback is being executed. Can anyone tell me what I'm doing wrong? The checkAuthentication function works fine, just not the callback function. Any ideas?
Here is a JSFiddle I made showing the issue.
https://jsfiddle.net/69z2wepo/16069/
checkAuthentication: function( cb ) {
this.setState({
loggedIn: true,
userId: 3243,
}, function(){
if (cb && (typeof cb == "function")) {
cb();
console.log("wtf");
}
});
},
componentDidMount: function() {
this.checkAuthentication( function() {
this.setState({
view: "user",
viewUserId: 54234,
});
}).bind(this);
},