我的 React 类组件中有以下代码。
出于某种原因,我观察到,在内部componentDidMount
,尽管await
在调用之前有关键字 to this.getKeyForNextRequest()
,但执行会跳转到下一个调用this.loadGrids()
.
我在这里做错了吗?
async componentDidMount() {
await this.getKeyForNextRequest();
await this.loadGrids();
}
getKeyForNextRequest = async () => {
const dataRequester = new DataRequester({
dataSource: `${URL}`,
requestType: "POST",
params: {
},
successCallback: response => {
console.log(response);
}
});
dataRequester.requestData();
}
loadGrids = async () => {
await this.loadGrid1ColumnDefs();
this.loadGrid1Data();
await this.loadGrid2ColumnDefs();
this.loadGrid2Data();
}