在我注销的应用程序中,我this.props.dispatch(setUserSession({}))
什至在这里传递了 null 。在 redux-logger 中调度后,我可以看到它已更改为
action {type: "SET_USER_SESSION", userSession: {}}
next state {userSession: {}
但是在本地存储中,我仍然可以看到在调度 null 之前存在的 userSession。持久存储将在什么操作或何时更新。
我在注销时将 userSession 设置为 null,但是当用户刷新页面时,由于令牌存在于商店中,因此他在没有登录的情况下重新登录。
而且我不想清除或刷新整个存储,只是那个 userSession 键。
当前商店配置
import { createStore, applyMiddleware, compose } from 'redux';
import thunk from 'redux-thunk';
import { persistStore, persistReducer } from 'redux-persist';
import storage from 'redux-persist/lib/storage';
import reducer from './reducers';
let middleware = [thunk];
const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
const configureStore = composeEnhancers(applyMiddleware(...middleware))(createStore);
const config = {
key: 'root',
storage
};
const combinedReducer = persistReducer(config, reducer);
const store = configureStore(combinedReducer);
const persistor = persistStore(store);
export { persistor, store };
请提供一些帮助,如果我遗漏了什么,请纠正我。