I have added, redux persist to my app. I have a root reducer which contains different reducers like "Auth", "Orders", "Products", "Transactions" etc.
problem is my Orders and Products reducer is persisted properly but Auth and Transactions reducer does not persist.
I tried debugging, I have can see no data in Auth and Transactions slice of root reducer
This is my top level config
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);
exporting like
export const configureStore = createStore(pReducer, composeEnhancers(applyMiddleware(thunk)));
export const persistor = persistStore(configureStore);
In My App.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;
Please check above code it working fine. and let me know if you still have any issue
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.