| 12345678910111213141516171819202122232425 |
- import { createStore, compose, applyMiddleware } from "redux";
- import thunk from "redux-thunk";
- import reducers from "./reducers/reducers";
- import { saveState } from "./persisted.store.cookies.js";
- export default function configureStore(initialState) {
- const enhancers = compose(typeof window !== "undefined" && window.devToolsExtension ? window.devToolsExtension() : (f) => f);
- // const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || enhancers;
- const store = createStore(
- reducers,
- enhancers(applyMiddleware(thunk))
- // {
- // ...initialState,
- // },
- // enhancers
- );
- // add a listener that will be invoked on any state change
- store.subscribe(() => {
- saveState(store.getState());
- });
- return store;
- }
|