【发布时间】:2019-04-10 03:21:41
【问题描述】:
参考代码
//Component
delete = (id) => {
this.props.deleteContentItem(id, this.props.history)
}
//action.js
export const deleteContentItem = (id, history) => dispatch => {
axios.delete(`${API_ROOT}/mcenter/admin/delete/${id}`)
.then(res => {
dispatch({
type: DELETE_CONTENT,
payload: res.data
})
history.push('/mcenter')
})
.catch(err =>
dispatch({
type: GET_ERRORS,
payload: err.response.data
})
);
}
我在/mcenter URL 中,删除操作后需要刷新同一页面。
我的问题是:
删除后不会重新渲染组件。
任何帮助将不胜感激。
【问题讨论】:
-
history.push('/mcenter')的用途是什么?这样做有什么目的吗? -
因为它没有重新渲染所以我试图强制它导航