Skip to content

Commit 44f6ddc

Browse files
committed
re-add missing configureStore.dev
1 parent ff60927 commit 44f6ddc

File tree

2 files changed

+44
-1
lines changed

2 files changed

+44
-1
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-redux-bootstrap-webpack-starter",
3-
"version": "0.6.0",
3+
"version": "0.6.1",
44
"description": "react js + redux + react router + hot reload + devTools + bootstrap + webpack starter",
55
"main": "src/index.js",
66
"scripts": {
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import { createStore, compose, combineReducers, applyMiddleware } from 'redux';
2+
import { persistState } from 'redux-devtools';
3+
import { routerReducer } from 'react-router-redux';
4+
import createLogger from 'redux-logger';
5+
import thunkMiddleware from 'redux-thunk';
6+
import * as reducers from '../modules/reducers';
7+
import DevTools from '../devTools/DevTools.jsx';
8+
9+
10+
const loggerMiddleware = createLogger({
11+
level : 'info',
12+
collapsed : true
13+
});
14+
15+
// createStore : enhancer
16+
const enhancer = compose(
17+
applyMiddleware(thunkMiddleware, loggerMiddleware), // logger after thunk to avoid undefined actions
18+
persistState(getDebugSessionKey()),
19+
DevTools.instrument()
20+
);
21+
22+
function getDebugSessionKey() {
23+
const matches = window.location.href.match(/[?&]debug_session=([^&]+)\b/);
24+
return (matches && matches.length > 0)? matches[1] : null;
25+
}
26+
27+
// combine reducers -> createStore reducer
28+
const reducer = combineReducers({
29+
...reducers,
30+
routing: routerReducer
31+
});
32+
33+
export default function configureStore(initialState) {
34+
const store = createStore(reducer, initialState, enhancer);
35+
// checks if webpack HMR:
36+
if (module.hot) {
37+
module.hot.accept('../modules/reducers', () =>
38+
store.replaceReducer(require('../modules/reducers').default)
39+
);
40+
}
41+
42+
return store;
43+
}

0 commit comments

Comments
 (0)