Skip to content

Commit

Permalink
Merge pull request #5 from molily/master
Browse files Browse the repository at this point in the history
configureStore: Use the new createStore sytax.
  • Loading branch information
sebastiandeutsch committed Sep 16, 2016
2 parents 0009666 + df03727 commit 400efc4
Showing 1 changed file with 20 additions and 19 deletions.
39 changes: 20 additions & 19 deletions src/reducers/configureStore.js
@@ -1,30 +1,31 @@
import { compose, createStore, applyMiddleware } from 'redux';
import thunk from 'redux-thunk';
import rootReducer from 'reducers';
import DevTools from 'containers/DevTools';

export default function configureStore(initialState) {
let store;

if (process.env.NODE_ENV == "production") {
const createStoreWithMiddleware = compose(
applyMiddleware(thunk),
)(createStore);
store = createStoreWithMiddleware(rootReducer);
} else {
const createStoreWithMiddleware = compose(
applyMiddleware(thunk),
// Store enhancer: Thunk middleware
let enhancer = applyMiddleware(thunk);

// Add development tools
if (process.env.NODE_ENV === 'development') {
// Require DevTools only in development
// so it is not included in the production build
const DevTools = require('containers/DevTools').default;
enhancer = compose(
enhancer,
DevTools.instrument()
)(createStore);
store = createStoreWithMiddleware(rootReducer);
);
}

const store = createStore(rootReducer, initialState, enhancer);

if (module.hot) {
// Enable Webpack hot module replacement for reducers
module.hot.accept('reducers', () => {
const nextReducer = require('reducers');
store.replaceReducer(nextReducer);
});
}
if (module.hot) {
// Enable Webpack hot module replacement for reducers
module.hot.accept('reducers', () => {
const nextReducer = require('reducers');
store.replaceReducer(nextReducer);
});
}

return store;
Expand Down

0 comments on commit 400efc4

Please sign in to comment.