Skip to content

Commit

Permalink
Create store using Redux Toolkit's configureStore
Browse files Browse the repository at this point in the history
  • Loading branch information
tomcur committed Jul 4, 2023
1 parent 03f5bf4 commit 9907303
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions astroplant-frontend/src/store.ts
Original file line number Diff line number Diff line change
@@ -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) => {
Expand All @@ -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);

0 comments on commit 9907303

Please sign in to comment.