這個方法中我更新currentType的值以后,在fetchQuestionIdList函數中用currentType作為參數去調接口,但是每次currentType都是我上次更新的值,選2傳送1,選3傳送2,選4傳送3....有什么方法解決這種延遲?或者我跟本不應該這樣用它作為參數,而是定義別的變量保存我選的值?this.setState只是用來重新渲染嗎? onClickItemType=(item)=>{
this.setState({ currentType:{ code:item.code, name:item.name
}, isShowTypeList: false
})
this.fetchQuestionIdList(this.state.navigationCode)}fetchQuestionIdList = async (tfcode) => {
let params = { navigationCode: tfcode, typeCode: currentType.code, diffCode: currentDiff.code, contentFinalFlag: true, thirdpartyType: 1
}
let systemQuestions = await matchExcerciseApi.getQuestionList(params) || {}}
react,this.setState數據更新
拉莫斯之舞
2018-07-23 09:35:18