1 回答

TA貢獻(xiàn)1810條經(jīng)驗(yàn) 獲得超5個(gè)贊
如果您正在更改減速器結(jié)構(gòu),您應(yīng)該遷移,或者按照 Jesse Schokker 的建議清除所有緩存,但如果您真的不想丟失其中的一些數(shù)據(jù),那么請進(jìn)行遷移。
import { createMigrate } from 'redux-persist';
const migrations = {
2: state => {
const { yourReducer } = state;
const mynewStructure = { ...yourReducer, myNewKey: 'some value' };
state.yourReducer = mynewStructure;
return state;
};
}
};
const persistConfig = {
...offlineConfig,
whitelist: excludeSaveActionConstants
version: 2, // Add a version which will correspond to the number declared in your migrate
migrate: createMigrate(migrations, { debug: false })
};
添加回答
舉報(bào)