에러노트

[에러노트] TypeError: _redux_configStore__WEBPACK_IMPORTED_MODULE_2__.default.push is not a functiongotoHome

자바칩 프라푸치노 2021. 9. 29. 22:49

이때 생긴 문제는 바로!

history를 import할때 {history}라고 안해서 생긴 에러다.

 

 

redux >

configStore.js

import { createStore, applyMiddleware, compose, combineReducers } from "redux";
import { createBrowserHistory } from "history";
import { connectRouter } from "connected-react-router";
import thunk from "redux-thunk";
import item from "./modules/item";
import cart from "./modules/cart";


const history = createBrowserHistory();
const rootReducer = combineReducers({
  item,
  cart,
  router: connectRouter(history),
});

const middlewares = [thunk.withExtraArgument({ history })];

const env = process.env.NODE_ENV;
if (env === "development") {
  const { logger } = require("redux-logger");
  middlewares.push(logger);
}

const composeEnhancers =
  typeof window === "object" && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__
    ? window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({
      // Specify extension’s options like name, actionsBlacklist, actionsCreators, serialize...
    })
    : compose;

const enhancer = composeEnhancers(applyMiddleware(...middlewares));

const store = createStore(rootReducer, enhancer);

export { history };
export default store;
728x90