【发布时间】:2020-01-18 23:29:37
【问题描述】:
我的渲染中有一个像这样调用的 handlePageClick 函数:
onPageChange={this.handlePageClick}
功能是:
handlePageClick = data => {
this.setState({
circleloading: true
});
let names = ["page"]
let values = [data.selected]
this.updatePublications(names,values)
}
由于某种原因,当我这样做时,函数会被无限调用?为什么?
但是,当我在其他时间调用的其他函数中执行完全相同的操作时,它可以正常工作。所以我想也许函数被“onPageChange”触发的事实有关系。
更新,这是我的 updatePublications 函数:
updatePublications(names,values){
let queryParameters = this.generateQueryParametersPackage();
this.updateQueryParameters(queryParameters,names,values)
this.pushParameters(names,values);
let currentComponent = this
PublicationService.getPublications(queryParameters).then(function (response){
if(response.status !== StatusCode.OK){
ErrorService.logError(currentComponent.props,response)
return;
}
currentComponent.setState({
// other variables ,
circleloading: false
})
currentComponent.updateFilters(queryParameters)
})
}
updateFilters(queryParameters){
let currentComponent = this
PublicationService.getFilters(queryParameters).then(function (response){
if(response.status !== StatusCode.OK){
ErrorService.logError(currentComponent.props,response)
return;
}
currentComponent.setState({
filters: response.data
})
currentComponent.hideEmptyFilters(response.data,"locations","filterLocationHeader");
})
}
【问题讨论】:
-
updatePublications是做什么的? -
@BrianThompson 刚刚更新了我的问题
-
使用您引用的循环包含代码可能也很有用。
标签: javascript reactjs