Reactjs 如何使用连接的react路由器重置Redux存储的状态?

Reactjs 如何使用连接的react路由器重置Redux存储的状态?,reactjs,redux,react-redux,redux-store,connected-react-router,Reactjs,Redux,React Redux,Redux Store,Connected React Router,我正试图改变这种完全相同的行为。除了我使用的是连接的路由器。我的配置如下所示: 减速器 export const rootReducer = history => combineReducers({ auth: auth.reducer, router: connectRouter(history), authentication: authenticationReducer, users: usersReducer, project: projec

我正试图改变这种完全相同的行为。除了我使用的是连接的路由器。我的配置如下所示:

减速器

export const rootReducer = history => combineReducers({
    auth: auth.reducer,
    router: connectRouter(history),
    authentication: authenticationReducer,
    users: usersReducer,
    project: projectReducer,
    domain: domainReducer,
    test: testReducer
});
贮藏

我试过了,但不起作用:

const appReducer = (state, action, history) => combineReducers({
    auth: auth.reducer,
    router: connectRouter(history),
    authentication: authenticationReducer,
    users: usersReducer,
    project: projectReducer,
    domain: domainReducer,
    test: testReducer
})

export const rootReducer = history => (state, action) => {
    if (action.type === actionTypes.LOGOUT_SUCCESS) {
        state = undefined;
    }
    return appReducer(state, action, history)
};
这似乎是一个与这个包裹。解决方案似乎是将状态设置为
initialState
值,而不是
undefined
。唯一需要注意的是,您不应该尝试重新初始化
路由器
——默认情况下应该这样做

const appReducer = (state, action, history) => combineReducers({
    auth: auth.reducer,
    router: connectRouter(history),
    authentication: authenticationReducer,
    users: usersReducer,
    project: projectReducer,
    domain: domainReducer,
    test: testReducer
})

const initialState = {
    // Don't reset router here
    auth: {},
    authentication: {},
    users: {},
    project: {},
    domain: {},
    test: {}
}

export const rootReducer = history => (state, action) => {
    if (action.type === actionTypes.LOGOUT_SUCCESS) {
        state = initialState;
    }
    return appReducer(state, action, history)
};

非常感谢。该链接还帮助我更改了返回到返回通知者(历史)(状态、操作);现在它开始工作了。我真的很感谢你的帮助。
const appReducer = (state, action, history) => combineReducers({
    auth: auth.reducer,
    router: connectRouter(history),
    authentication: authenticationReducer,
    users: usersReducer,
    project: projectReducer,
    domain: domainReducer,
    test: testReducer
})

const initialState = {
    // Don't reset router here
    auth: {},
    authentication: {},
    users: {},
    project: {},
    domain: {},
    test: {}
}

export const rootReducer = history => (state, action) => {
    if (action.type === actionTypes.LOGOUT_SUCCESS) {
        state = initialState;
    }
    return appReducer(state, action, history)
};