为了账号安全,请及时绑定邮箱和手机立即绑定

react,this.setState数据更新

react,this.setState数据更新

拉莫斯之舞 2018-07-23 09:35:18
这个方法中我更新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) || {}}
查看完整描述

1 回答

  • 1 回答
  • 0 关注
  • 1495 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号