Open dayhaysoos opened 5 years ago
Still having issues with this. I don't think the functions inside the migrations object are being called at all
From my experiments, I find:
version
used in persistConfig. I only tried integers. I assume strings work too because integer keys on objects seem to get cast to strings anyway.So, to run your migrations[1]
...
import { createMigrate, persistStore, persistReducer } from 'redux-persist';
import thunk from 'redux-thunk';
import rootReducer from './reducers/index'; // this must export a store with a `claudio` key
import storage from 'redux-persist/lib/storage';
const migrations = {
0: (state) => ({
...state,
claudio: {}
}),
1: (state) => ({
claudio: state.favorites.moves.claudio,
})
};
const persistConfig = {
key: 'root',
version: 1, // version must match the migrations keys
storage,
migrate: createMigrate(migrations, { debug: true }),
whitelist: [
'settings',
'favorites',
'claudio', // if you whitelist reducers, you must include your new reducer in your list
],
};
//... the rest of your code looked fine
I used migration to add an object and it worked just fine. I needed to add another object but it doesn't seem to work this time:
When it worked the first time, the "claudio" value was "shaheen" and I ticked the version up to 1.
As you can see, I replaced shaheen with claudio and now i"m on version 3.6. With debug on, it shows the migrationKeys array is empty.
Is there anything else I should be changing to get this to work?