Skip to content

Commit

Permalink
Setup redux for state migrations
Browse files Browse the repository at this point in the history
Signed-off-by: Giovanni Baratta <[email protected]>
  • Loading branch information
giovannibaratta committed May 23, 2024
1 parent 82b9c67 commit 9d32c48
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/state/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down

0 comments on commit 9d32c48

Please sign in to comment.