Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevents Hot Loader from Refreshing Page #36

Closed
garretto opened this issue Jan 15, 2016 · 13 comments
Closed

Prevents Hot Loader from Refreshing Page #36

garretto opened this issue Jan 15, 2016 · 13 comments

Comments

@garretto
Copy link

Found another issue. I'm using react-transform-hmr and this extension prevents the page from refreshing if a full refresh is required. For example, if I change code in my action creators. Instead of refreshing, I get a JavaScript TypeError saying e is not a function. Then I have to refresh the page manually.

Any ideas? Thanks!

@zalmoxisus
Copy link
Owner

As far as I know, HMR deals only with reducers (if you enable it in your store) as you can use replaceReducer for that. For action creators you do have to refresh the page manually. Does it work when you disable the extension?

About the "JavaScript TypeError saying e is not a function" cannot reproduce it with the counter example. Could you share an example? BTW, it would be a great contribution to have here a simple ImmutableJS example to check it when we implement new features.

@zalmoxisus
Copy link
Owner

Hey @garretto,

Even though I cannot reproduce it, should be fixed in 0.4.16. Could you please give it a try?

@gaearon
Copy link

gaearon commented Jan 29, 2016

For action creators you do have to refresh the page manually.

To be fair action creators should be reloaded if you use React Hot Loader. They don't with React Transform—we'll fix that eventually but not very soon.

@garretto
Copy link
Author

@zalmoxisus I tried with the new version and no dice. Something in the plugin prevents a full page reload. Also for editing reducers actually. Ended up just installing redux-dev-tools into my project and it works fine there.

Also should have mentioned I'm using react-transform-hmre @gaearon not react-hot-loader. Thanks for creating both of those by the way. :)

@garretto
Copy link
Author

If I get some time I'll try to reproduce with the counter example.

@zalmoxisus
Copy link
Owner

That's strange, just tried babel-preset-react-hmre and don't see any difference. As I see, it also includes react-transform-hmr. A PR to the counter example to reproduce that, would be welcome.

@nirrek
Copy link

nirrek commented Jan 30, 2016

The .babelrc of the react-transform-boilerplate looks like this:

{
  "presets": ["react", "es2015"],
  "env": {
    "development": {
      "presets": ["react-hmre"]
    }
  }
}

Whereas the .babelrc of the counter example looks like this:

{
  "presets": [ "es2015", "stage-0", "react" ],
  "plugins": [ "add-module-exports", "transform-decorators-legacy" ]
}

If you remove the add-modules-exports plugin from the counter example's .babelrc, you will see the error @garretto refers to. Namely: TypeError: e is not a function will be printed inside the devtools window if you update a reducer (counter.js in this particular case).

Similarly, if you install babel-plugin-add-modules-exports and add it to the .babelrc of your react-transform-boilerplate based project, hot loading of reducers should work.

@zalmoxisus
Copy link
Owner

@nirrek, thanks for the explanation. In the unbuilt (unuglified) extension TypeError: e is not a function becomes TypeError: reducer is not a function. Without the extension (and DevTools at all) I also get this error as TypeError: currentReducer is not a function and hmr doesn't work. While changing const nextReducer = require('../reducers'); to const nextReducer = require('../reducers').default; fixes it, which is actually the same as we get with babel-plugin-add-modules-exports.

I'm curious to see the case when the error occurs only with the extension enabled and especially looking forward to seeing how we can get actions hot reloaded.

@gaearon
Copy link

gaearon commented Jan 30, 2016

FYI we added an explicit error message in Redux 3.1.5 for this.
reduxjs/redux#1321

@zalmoxisus
Copy link
Owner

@gaearon, unfortunately, this doesn't help in our case as replaceReducer doesn't get the nextReducer directly, but through liftReducer. May I add that exception also into the liftReducer's function?

@gaearon
Copy link

gaearon commented Jan 30, 2016

Oh, good point. Want to make a PR?

@zalmoxisus
Copy link
Owner

@gaearon, gladly :)
I added the same message about nextReducer there as to be easier to google the error.

@zalmoxisus
Copy link
Owner

Should be fixed in v1.0.0-beta3 with more descriptive error. Thanks, @gaearon, the provided explanation for the error is great!

@garretto, if you still have that error and have time to provide an example or to add some hints on how to reproduce it, please reopen the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants