Redux-Persist - 无法完全重置状态

pho*_*bus 6 javascript local-storage reactjs redux redux-persist

我在我的 React 应用程序中使用 redux-persist 。注销时,我想完全重置 redux 状态并删除所有本地存储数据。

这是我的注销操作,其中我从后端删除刷新令牌,然后在调度 RESET 之前对 redux 存储持久器调用 purge。

export const logout = () => (dispatch) => {
    if (localStorage.refreshToken) {
        axios.post(`${API_URL}/logout`, {token: localStorage.refreshToken}).then( async () => {
            // rest redux-persist
            await persistor.purge();
            dispatch({ type: RESET });
        });
    }
}
Run Code Online (Sandbox Code Playgroud)

在我的根减速器中,我按照此处的答案来处理此重置操作:

const appReducer = combineReducers({
    /* app level reducers...*/
});

const rootReducer =  (state, action) => {
    console.log("Reducing action: ", action);
    if (action.type === RESET) {
        // reset state
        state = undefined;
        // reset local storage
        localStorage.clear();
    }
    return appReducer(state, action)
}

export default rootReducer;
Run Code Online (Sandbox Code Playgroud)

我可以看到我的令牌已从本地存储中清除,而且最后触发的操作确实是重置操作。但本地存储仍然包含persist:root来自 redux-persist 的内容。有谁知道为什么它没有被删除或者我如何实现我想要做的事情?