React native redux持久化:旧数据覆盖还原程序-反应本机
场景是将与用户相关的详细信息存储在减速机中。当用户a注销设备,用户B登录设备时,数据将被删除,新的用户数据将存储在reducer中。但当应用程序关闭并从退出状态启动时,用户A的数据将从持久化存储到reducer中 我的商店配置代码如下:React native redux持久化:旧数据覆盖还原程序-反应本机,react-native,redux,react-redux,persist,redux-persist,React Native,Redux,React Redux,Persist,Redux Persist,场景是将与用户相关的详细信息存储在减速机中。当用户a注销设备,用户B登录设备时,数据将被删除,新的用户数据将存储在reducer中。但当应用程序关闭并从退出状态启动时,用户A的数据将从持久化存储到reducer中 我的商店配置代码如下: import {createStore, compose, applyMiddleware} from 'redux'; import {persistStore, persistCombineReducers} from 'redux-persist'; im
import {createStore, compose, applyMiddleware} from 'redux';
import {persistStore, persistCombineReducers} from 'redux-persist';
import AsyncStorage from '@react-native-community/async-storage';
import {createLogger} from 'redux-logger';
import createSagaMiddleware from 'redux-saga';
import rootReducers from '../reducers'; // where reducers is a object of reducers
import sagas from '../sagas';
const config = {
key: 'root',
storage: AsyncStorage,
blacklist: ['loadingReducer'],
debug: true, //to get useful logging
};
const middleware = [];
const sagaMiddleware = createSagaMiddleware();
middleware.push(sagaMiddleware);
if (__DEV__) {
middleware.push(createLogger());
}
const reducers = persistCombineReducers(config, rootReducers);
const rootReducer = (state, action) => {
if (action.type === 'LOG_OUT') {
return reducers(undefined, action);
}
return reducers(state, action);
};
const enhancers = [applyMiddleware(...middleware)];
const persistConfig = {enhancers};
const store = createStore(rootReducer, undefined, compose(...enhancers));
const persistor = persistStore(store, persistConfig, () => {
// console.log('Test', store.getState());
});
const configureStore = () => {
return {persistor, store};
};
sagaMiddleware.run(sagas);
export default configureStore;
我曾尝试在用户尝试注销时使用AsyncStorage.removeItem('persist:root')
,但没有任何更改。旧数据被持久化,即使它本应被覆盖
知道是什么造成了这种奇怪的局面吗