Is it correct to use await setState()?
You can't await this.setState
for the reasons already stated. But you can write your own awaitable setState function easily:
promisedSetState = (newState) => new Promise(resolve => this.setState(newState, resolve));
now you can call
await promisedSetState({ someState: true });
No this.setState
doesn't return a promise.
So you can't use await in this case. You need to use the callback.