在react-redux中重新加载页面的正确方法是什么?

时间:2017-08-07 08:19:03

标签: reactjs react-redux react-router-redux

使用react-router-redux进行页面重新加载的正确方法是什么?

我们通常以这种方式推动一个新的状态,

export function doTask() {
    return dispatch => {
        dispatch(DoTask.request());
        fetch(`${API}/doTask`, get())
            .then(status)
            .then(_ => dispatch(doTask.success()))
            .then(_ => dispatch(push('/dashboard')))
            .catch(error => dispatch(DoTask.failure(error))) }}

我想知道以这种方式触发页面重新加载是否是一个好习惯,

.then(_ => window.location.reload())

有更好的选择吗?

1 个答案:

答案 0 :(得分:4)

您可以使用window.location.reload()