Pablo Cegarra Pablo Cegarra - 19 days ago 10
React JSX Question

Another cannot read props on callback

On the submit button I'm checking if the user is ok.
But I can't access to my props on the callback.

Meteor.loginWithPassword({username:username}, password, function(error){
if(!error){
this.props.router.push('/');
}
});


constructor(props) {
super(props)

this.state = {
username: '' ,
password:'',
errors: [],
alertVisible: false
};


My button:

<Button type='submit' onClick={this.onClickLogIn.bind(this)}>Go</Button>


What should I do?

Answer

Solved:

Meteor.loginWithPassword({username:username}, password, (error) => {
  if(!error){
    this.props.router.push('/ltr/dashboard');
  }
});
Comments