Skip to content Skip to sidebar Skip to footer

Method Executed Before 'await' Method Complete

Trying to perform setState after the value return from checkPermissions(), however async-await didn't do the job. I can't spot anything incorrect here, can you point out my mistake

Solution 1:

You are presumably looking for

async componentDidMount() {
  const permissions = await PushNotification.checkPermissions();
  console.log(permissions); 
  const authorizationStatus = permissions.alert
  console.log('Run first');

  console.log('Run after')
  this.setState({authorizationStatus});
}

You can only await a promise, you don't want to pass a callback.


Post a Comment for "Method Executed Before 'await' Method Complete"