react的一個項目,刪除照片的功能,在點擊刪除照片后,需要更新組件,重新獲取列表的值,兩個函數(shù)體請求攜帶的id不一樣,請求都是異步函數(shù),如果根據(jù)返回的值再發(fā)起第二個請求,id值不同,請教各位大佬,這個是刪除照片的函數(shù)handleDelete = id => {const { dispatch } = this.props;
dispatch({
type: 'slot/delPhoto',
id,
});//this.forceUpdate(); setTimeout(this.loadData(),2000)};這個是獲取列表的函數(shù)loadData(){const { dispatch, match: { params: { id } } } = this.props;
dispatch({ type: 'slot/fetchAudit',
id,
});//this.forceUpdate();}我想通過this.forceUpdate()來強(qiáng)制更新組件但是無效,下面是請求的兩個函數(shù),*delPhoto({ id }, { call, put }) { const response = yield call(delPhoto, id); if (response.status === true) {
message.success('操作成功');
} else {
message.error('操作失敗');
}
},*fetchAudit({ id }, { call, put }) { const response = yield call(getAuditSlot, id); if (response.status === true) { yield put({
type: 'queryAudit',
payload: response.data,
});
}
},
請教各位大佬,我用的是dva的數(shù)據(jù)層框架
react異步更新組件
慕森王
2019-02-09 22:47:40