redux-persist
redux-persist copied to clipboard
Enable `createMigrate` to handle async migrations #866
via: https://github.com/rt2zz/redux-persist/issues/806
const migrations = {
0: (state) => {
// migration clear out device state
return {
...state,
device: undefined
}
},
// You can use also `async () => {}` function
// For example to move users to other storage
1: async ({ users, ...state }) => {
try {
await insertToOtherStorage(users)
return state
} catch (e) {
// Don't forget about exceptions
return state
}
},
2: (state) => {
// migration to keep only device state
return {
device: state.device
}
}
}
Any progress?
cc @ckalika