an item of react, the function of deleting a photo. After clicking to delete a photo, you need to update the component and get the value of the list again. The two function body requests carry different id, and the request is an asynchronous function. If you launch a second request according to the returned value, the id value is different, ask the bosses, this is the function of deleting photos
handleDelete = id = > {
const { dispatch } = this.props;
dispatch({
type: "slot/delPhoto",
id,
});
//this.forceUpdate();
setTimeout(this.loadData(),2000)
};
this is the function to get the list
loadData () {
const { dispatch, match: { params: { id } } } = this.props;
dispatch({
type: "slot/fetchAudit",
id,
});
//this.forceUpdate();
}
I want to force the update of the component through this.forceUpdate (), but it doesn"t work. Here are two functions of the request:
* 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