so in my react code I have this:
  componentDidMount = () => {
    firebase.auth().getRedirectResult().then(function(result) {
        if (result.credential) {
          var token = result.credential.accessToken;
        }
        var ruser = result.user;
        console.log(ruser.displayName, 'lol'); //THIS LOGS CORRECTLY
      }).catch(function(error) {
        var errorCode = error.code;
        var errorMessage = error.message;
        var email = error.email;
        var credential = error.credential;
      }).then(function(result){
        this.setState({user: ruser});
        console.log(result, 'rslt'); //THIS LOGS UNDEFINED 
      });
  }
I basically want to set the state of the user who is logged in. however, I get undefined when I pass this down, what have I done wrong with promises? i want to just pass down the result and make it available outside the scope of the function...
 
     
    