emmenko / redux-react-router-async-example

A showcase of the Redux architecture with React Router
http://emmenko.github.io/redux-react-router-async-example
MIT License
936 stars 131 forks source link

Error when hot reloading i18n files #29

Closed jonaswindey closed 8 years ago

jonaswindey commented 8 years ago

When you change something in the locales, you get the following error:

<Provider> does not support changing `store` on the fly.
It is most likely that you see this error because you updated to Redux 2.x and React Redux 2.x which no longer hot reload reducers automatically. 
See https://github.com/rackt/react-redux/releases/tag/v2.0.0 for the migration instructions.

Although looking at the code in configure-store.js, it seems that you followed the changes correctly.

emmenko commented 8 years ago

Yeah, I think it happens whenever you change something in the index.js file. I can try to find a solution for that...

gaearon commented 8 years ago
module.hot.accept('./i18n', () => {
  let i18n = require('./i18n');
  // do something with the new version to re-render
});
emmenko commented 8 years ago

@jonaswindey I've kept now index.js very simple so that it doesn't get easily hot reloaded, hence the warning is gone if you update for example the locales.

screen shot 2015-09-28 at 22 16 14

@gaearon thanks for the tip. I'm not sure how to use it though as it's used here and I'm not sure how should I replace it.

If I do it this way and I try to change something nothing actually re-renders although I can see in the console that it's updated...

diff --git lib/Root.js lib/Root.js
index 8d61fc3..409e56d 100644
--- lib/Root.js
+++ lib/Root.js
@@ -9,7 +9,7 @@ import configureStore from './utils/configure-store'
 import * as storage from './persistence/storage'
 import * as components from './components'
 import * as constants from './constants'
-import * as i18n from './i18n'
+// import * as i18n from './i18n'

 const {
   About,
@@ -34,6 +34,11 @@ const initialState = {

 export const store = configureStore(initialState)

+let i18n = require('./i18n')
+module.hot.accept('./i18n', () => {
+  i18n = require('./i18n')
+})
+
 function getRootChildren (props) {
   const intlData = {
     locale: props.application.locale,
screen shot 2015-09-28 at 22 23 26

Can you give me an hint maybe how it needs to be done correctly? Thanks!