I want to write a migration for redux-persist, but somehow migration is not being applied. I've followed the official documentation about migrations: https://github.com/rt2zz/redux-persist/blob/master/docs/migrations.md
But something in the code below is not working since my redux-persist is not applying the migration.
When I try to debug this migration it says that version number is the same.
Redux-persist version match noop migration
Not sure if I'm missing something in the config or migration writing.
In my store I have something like this for persist configuration
const persistConfig: PersistConfig = {
key: 'primary',
storage,
blacklist: [
],
stateReconciler: autoMergeLevel2,
version: 1,
migrate: createMigrate(migrations, { debug: true })
} as PersistConfig;
and my migration looks like:
const migrations = {
0: (state: StoreState) => {
return {
...state,
application: {
...state.application
}
}
},
1: (state: StoreState) => {
return {
...state,
application: {
...state.application,
items:[{id: 1, isDone: false}, {id: 2, isDone: false}].map((item, index)=>{
if(item.id == 1){
item.isDone = true
}
}),
},
}
}
}
In my first version of the state and application reducer I had object items which looked like this:
items:[
{id: 1},
{id: 2}
]
and now it needs to look like:
items:[
{id: 1, isDone: false/true},
{id: 2, isDone: false/true}
]