rt2zz / redux-persist

persist and rehydrate a redux store
MIT License
12.94k stars 866 forks source link

Redux persist migration empty migrationKeys #1312

Open arled opened 3 years ago

arled commented 3 years ago
"redux-persist": "^6.0.0",
"react": "16.13.1",
"react-native": "0.63.4",

export const migrations = {
  0: (state: any) => {
    return {
      ...state,
      someObject: { ...state.someObject, someItem: true },
    };
  },
};

import { configureStore } from '@reduxjs/toolkit';
import AsyncStorage from '@react-native-async-storage/async-storage';
...
const persistConfig = {
  key: 'root',
  storage: AsyncStorage,
  version: 3,
  migrate: createMigrate(migrations, { debug: true }),
};

const persistedReducer = persistReducer(persistConfig, rootReducer);
...

migration executes but migrationKeys are empty and nothing migrates.

Screenshot 2021-06-07 at 18 42 19
mattrabe commented 7 months ago

@arled I couldn't find documentation for it, but the object keys in the first param passed to createMigrate (your migrations const) apparently need to match the target version. Your target version is 3, so it should be 3: (state: any) => { ... } instead of 0