fleet/frontend/redux/store.js

32 lines
869 B
JavaScript
Raw Normal View History

import { applyMiddleware, compose, createStore } from "redux";
import { browserHistory } from "react-router";
import { routerMiddleware } from "react-router-redux";
import thunkMiddleware from "redux-thunk";
import authMiddleware from "./middlewares/auth";
import redirectMiddleware from "./middlewares/redirect";
import reducers from "./reducers";
2016-09-07 00:04:02 +00:00
const initialState = {};
const appliedMiddleware = applyMiddleware(
2016-09-07 00:04:02 +00:00
thunkMiddleware,
routerMiddleware(browserHistory),
authMiddleware,
2021-04-14 16:52:15 +00:00
redirectMiddleware
);
2016-09-07 00:04:02 +00:00
const composeEnhancers =
process.env.NODE_ENV !== "production" &&
typeof global.window === "object" &&
global.window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__
? global.window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__
: compose;
2016-09-07 00:04:02 +00:00
const store = createStore(
reducers,
initialState,
composeEnhancers(appliedMiddleware)
2016-09-07 00:04:02 +00:00
);
2016-09-07 00:04:02 +00:00
export default store;