I have working redux-persist code for one reducer in redux-persist store. I give initial state of reducer to store and after every change in state structure of reducer I update the migration number (which is 25 in this example) and it works fine. But I want to have multiple reducers and run migrations on them separately (according to the need to update them). I have also tried automergelevel2 but it does not updates the key in nested state key. Or is there any other approach instead of applying migrations and automergelevel2.
import rootReducer from "../reducers";
import {persistStore, persistReducer, createMigrate} from 'redux-persist';
import storage from 'redux-persist/lib/storage';
import {initialState} from "../reducers/authentication";
const middleware = [thunk];
const MIGRATION_DEBUG = false;
const migrations = {
25: state => initialState
};
const persistConfig = {
key: 'persistedReducer',
storage: storage,
version: 25,
migrate: createMigrate(migrations, {debug: MIGRATION_DEBUG}),
whitelist: [
'authentication',
]
};
const persistedReducer = persistReducer(persistConfig, rootReducer);
const store = createStore(persistedReducer, composeWithDevTools(applyMiddleware(...middleware)));
const persistor = persistStore(store);
export {persistor, store}