Skip to content

Commit 69947a3

Browse files
committed
fix issue with redux HMR (reduxjs/redux#667 (comment))
1 parent 9a51ed9 commit 69947a3

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

src/index.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,15 @@ ReactDOM.render((
3737
</Provider>
3838
), document.getElementById('root')
3939
);
40+
41+
42+
if (module.hot) {
43+
module.hot.accept();
44+
45+
// fix hot module replacement for reducers
46+
module.hot.accept('./ducks/index', () => {
47+
const nextRootReducer = require('./ducks/index');
48+
49+
store.replaceReducer(nextRootReducer);
50+
});
51+
}

src/redux-store.js

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,5 @@ export default function configureStore(initialState) {
4444
);
4545
}
4646

47-
48-
if (module.hot) {
49-
module.hot.accept('./ducks/index', () => {
50-
const nextRootReducer = require('./ducks/index');
51-
52-
store.replaceReducer(nextRootReducer);
53-
});
54-
}
55-
5647
return store;
5748
}

0 commit comments

Comments
 (0)