我已经添加了,redux 持久化到我的应用程序中。我有一个根化简器,其中包含不同的化简器,如"身份验证"、"订单"、"产品"、"交易"等。
问题是我的订单和产品缩减器正确保留,但身份验证和事务缩减器未保留。
我尝试调试,我在根还原器的身份验证和事务切片中看不到任何数据
这是我的顶级配置
const persistConfig = {
key: 'root',
storage,
// blacklist: ['navigation'] pass state which you want to ignore
blacklist: ['navigation', 'Error', 'Address', 'form'],
stateReconciler: autoMergeLevel2,
};
const pReducer = persistReducer(persistConfig, rootReducer);
像
export const configureStore = createStore(pReducer, composeEnhancers(applyMiddleware(thunk)));
export const persistor = persistStore(configureStore);
在我的应用中.js
<Provider store={store}>
{/* the loading and persistor props are both required! */}
<PersistGate loading={<Spinner />} persistor={persistor}>
<CommuneVendorRoot />
</PersistGate>
</Provider>
import { persistCombineReducers } from 'redux-persist'
import storage from 'redux-persist/es/storage'
import todos from '../reducers/reducers';
import autoMergeLevel2 from 'redux-persist/lib/stateReconciler/autoMergeLevel2';
console.log(todos)
const config = {
key: 'root',
storage: storage,
debug: true,
stateReconciler: autoMergeLevel2
};
const rootReducer = persistCombineReducers(config, {
Transactions: todos
});
export default rootReducer;
请检查上面的代码它工作正常。 并让我知道,如果你 仍然有任何问题