From 9907303ad4141db503e1bb2a3f89e5740ea94dd6 Mon Sep 17 00:00:00 2001 From: Thomas Churchman Date: Tue, 4 Jul 2023 16:20:18 +0200 Subject: [PATCH] Create store using Redux Toolkit's configureStore --- astroplant-frontend/src/store.ts | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/astroplant-frontend/src/store.ts b/astroplant-frontend/src/store.ts index 62882ad..217f92f 100644 --- a/astroplant-frontend/src/store.ts +++ b/astroplant-frontend/src/store.ts @@ -1,6 +1,14 @@ -import { applyMiddleware, createStore } from "redux"; +import { configureStore } from "@reduxjs/toolkit"; import { createEpicMiddleware } from "redux-observable"; -import { persistStore } from "redux-persist"; +import { + FLUSH, + REHYDRATE, + PAUSE, + PERSIST, + PURGE, + REGISTER, + persistStore, +} from "redux-persist"; import { rootEpic, rootReducer } from "./root"; const logger = (store: any) => (next: any) => (action: any) => { @@ -18,10 +26,15 @@ const logger = (store: any) => (next: any) => (action: any) => { const epicMiddleware = createEpicMiddleware(); -export const store = createStore( - rootReducer, - applyMiddleware(logger, epicMiddleware) -); +export const store = configureStore({ + reducer: rootReducer, + middleware: (getDefaultMiddleware) => + getDefaultMiddleware({ + serializableCheck: { + ignoredActions: [FLUSH, REHYDRATE, PAUSE, PERSIST, PURGE, REGISTER], + }, + }).concat([logger, epicMiddleware]), +}); export const persistor = persistStore(store); epicMiddleware.run(rootEpic);