redux-persist icon indicating copy to clipboard operation
redux-persist copied to clipboard

Redux persist migration empty migrationKeys

Open arled opened this issue 4 years ago • 1 comments

"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

arled avatar Jun 08 '21 00:06 arled

@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

mattrabe avatar Feb 09 '24 21:02 mattrabe