Move all samples to the root dir
Signed-off-by: Anca Iordache <anca.iordache@docker.com>
This commit is contained in:
37
react-express-mysql/frontend/src/app/store.js
vendored
Executable file
37
react-express-mysql/frontend/src/app/store.js
vendored
Executable file
@@ -0,0 +1,37 @@
|
||||
import { routerMiddleware } from 'react-router-redux';
|
||||
import { createStore, applyMiddleware, compose } from 'redux';
|
||||
import createSagaMiddleware from "redux-saga";
|
||||
import { rootReducer } from "./reducers";
|
||||
|
||||
export const sagaMiddleware = createSagaMiddleware();
|
||||
|
||||
export const configureStore = (history, initialState = {}) => {
|
||||
|
||||
const middlewares = [
|
||||
routerMiddleware(history),
|
||||
sagaMiddleware
|
||||
];
|
||||
|
||||
const enhancers = [
|
||||
applyMiddleware(...middlewares),
|
||||
];
|
||||
|
||||
if(__DEV__) {
|
||||
const devToolEnhancer = () => {
|
||||
return typeof window === 'object' && typeof window.devToolsExtension !== 'undefined'
|
||||
? window.devToolsExtension() : f => f;
|
||||
};
|
||||
enhancers.push(devToolEnhancer())
|
||||
}
|
||||
|
||||
const store = createStore(rootReducer, initialState, compose(...enhancers));
|
||||
|
||||
if(__DEV__ && module.hot) {
|
||||
module.hot.accept('./reducers', () => {
|
||||
const nextReducer = require('./reducers').default;
|
||||
store.replaceReducer(nextReducer);
|
||||
})
|
||||
}
|
||||
|
||||
return store;
|
||||
};
|
Reference in New Issue
Block a user