From 69947a3cd7ca78c6c70c346dad2046807acf54f2 Mon Sep 17 00:00:00 2001 From: maullerz Date: Mon, 21 Nov 2016 19:29:57 +0300 Subject: [PATCH] fix issue with redux HMR (https://github.com/reactjs/redux/pull/667#issuecomment-255372420) --- src/index.js | 12 ++++++++++++ src/redux-store.js | 9 --------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/index.js b/src/index.js index 5e436f1..9a9fc86 100644 --- a/src/index.js +++ b/src/index.js @@ -37,3 +37,15 @@ ReactDOM.render(( ), document.getElementById('root') ); + + +if (module.hot) { + module.hot.accept(); + + // fix hot module replacement for reducers + module.hot.accept('./ducks/index', () => { + const nextRootReducer = require('./ducks/index'); + + store.replaceReducer(nextRootReducer); + }); +} diff --git a/src/redux-store.js b/src/redux-store.js index 83e905d..cfdb111 100644 --- a/src/redux-store.js +++ b/src/redux-store.js @@ -44,14 +44,5 @@ export default function configureStore(initialState) { ); } - - if (module.hot) { - module.hot.accept('./ducks/index', () => { - const nextRootReducer = require('./ducks/index'); - - store.replaceReducer(nextRootReducer); - }); - } - return store; }