From 9d32c48709900a3f8fe5daead40cf76ef9635ca2 Mon Sep 17 00:00:00 2001 From: Giovanni Baratta Date: Thu, 23 May 2024 11:56:31 +0200 Subject: [PATCH] Setup redux for state migrations Signed-off-by: Giovanni Baratta --- src/state/store.ts | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/state/store.ts b/src/state/store.ts index bd0411b..8afd77f 100644 --- a/src/state/store.ts +++ b/src/state/store.ts @@ -4,13 +4,24 @@ import {useDispatch, useSelector} from "react-redux" import incomeReducer from "./income/income-reducer.ts" import settingsReducer from "./settings/settings-reducer.ts" import storage from "redux-persist/lib/storage" -import {persistReducer, persistStore} from "redux-persist" +import {createMigrate, persistReducer, persistStore} from "redux-persist" import houseReducer from "./house/house-reducer.ts" +const migrations = { + // @ts-expect-error The old state is not typed and redux-persist does + // not expose the types + 0: (state) => { + return { + ...state + } + } +} const persistConfig = { - key: "root", - storage + key: "when-i-will-go-broke-primary", + storage, + version: 0, + migrate: createMigrate(migrations) } const reducers = combineReducers({