0

I would like to navigate to new screen only if login is successful, I tried using {Actions.HomeScreen} inside if condition but it does not do anything.

here is the code:

async login() {
const res = await api.getLoginResult();
const status= res.status;
console.log('log'+status);
if(status==='success'){
  {Actions.HomeScreen;}
}

}
Siddarth G
  • 779
  • 11
  • 34

1 Answers1

1

You've forgotten to actually invoke the function, it should be:

async login() {
  const res = await api.getLoginResult();
  const status = res.status;
  console.log('log' + status);
  if(status === 'success') {
    Actions.HomeScreen(); // Note the parens ()
  }
}
Tom Walters
  • 15,366
  • 7
  • 57
  • 74