createMigrate not triggered
Hello, I am using redux-persist in a React Native project. Everything is working fine but impossible to create a migration. The debugMode is at true but nothing is logged in my console, version is well incremented for the action persist/PERSIST, but then the store is simply rehydrated as it used to be without any change.
Here is my code:
const storage = createSecureStorage()
export const migrations = {
20: (state) => ({ ...state, user: { ...state.user, hello: true } }),
}
const persistConfig = {
key: 'storage',
version: 20,
storage,
migrations: createMigrate(migrations, { debug: true }),
whitelist: ['user'],
blacklist: [],
}
export const rootReducer = combineReducers({
[api.reducerPath]: api.reducer,
user: userReducer,
})
const persistedReducer = persistReducer(persistConfig, rootReducer)
export const store = configureStore({
reducer: persistedReducer,
middleware: (getDefaultMiddleware) =>
getDefaultMiddleware({
serializableCheck: false,
}).concat(api.middleware),
})
export const persistor = persistStore(store)
Any idea?
I am experiencing the same issue, I tried to restore redux packages to versions where I remember the migration used to work but it did not fix it.
The old versions I tested:
"react-redux": "7.2.2", "redux": "4.0.5", "redux-persist": "^6.0.0", "redux-thunk": "2.3.0"
Not sure if its might be related to other packages or not. I am using react 17.0.2 & react-native 0.67.4
Also when I migrate a version I can see in the log:
LOG redux-persist: migrationKeys [9]
LOG redux-persist: running migration for versionKey 9
But the issue is that the returned state I set in the function is not being returned instead its rehydrated state as before the migration.
I think createMigrate is broken. When using the Promise.resolve method mentioned https://github.com/rt2zz/redux-persist/blob/master/docs/migrations.md it works