-
Notifications
You must be signed in to change notification settings - Fork 801
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
hmr + redux @connect() class decorator issue #1120
Comments
Sorry, was quite busy with a new release. Could you check your problem with version 4.6.0? |
No problem. I updated the test repo to 4.6.0 but unfortunately the issue persists. |
I'm seeing the same issue with using @connect()
class Thing extends Component { /**/ }
export default hot(module)(Thing); So this seems to suggest it's an ordering problem of some sorts: calling const hotConnect = (...connectArgs) =>
(component) =>
connect(...connectArgs)(hot(module)(component));
@hotConnect()
export default class Thing extends Component { /**/ } I'm a bit confused myself as to what's the best practice - if |
You may have one |
Allright, good to know! Just for the record, using the new |
I'll take a look on your case later today. Please don't fix it. |
This is React-Redux v6 issue.From our side it's tracked as #1001 this.selectChildElement = makeChildElementSelector() During the class update we consider updating of the factored method as unsafe, and NOT doing it. Result - you are rendering the old WrappedComponent. Solutions:
Whys:
@markerikson - could you take a look at the problem? I would really appreciate if Redux and RHL would be besties 🤝 |
I've got other priorities at the moment, but if someone wants to investigate this further and file a PR, we can look at it. |
This would fix the problem for now - reduxjs/react-redux#1137 |
Description
When using babel's
@babel/plugin-proposal-decorators
with redux's connect HOC and you make changes to the file the app updates but displays the old code.Here's the normal way which works as expected when you change the file:
If you use the class decorator it no longer renders new code:
I've tested this with other HOC like react-router's
withRouter
and the class decorator works fine. I'm unsure if this issue has to do with babel, hmr, or maybe I'm missing something obvious. I also transpiled the code with babel cli manually and tested the code it produces but that works fine, which is weird.Expected behavior
The file should hot reload successfully whether you're using the standard method or class decorator.
Actual behavior
When using redux connect as a class decorator old code gets rendered as you change the file.
Environment
React Hot Loader version: 4.3.12
Node: v8.12.0
npm: 6.4.1
@babel/core: 7.2.0
@babel/plugin-proposal-decorators: 7.2.0
Operating system: macOS Mojave 10.14.1
Browser and version: Chrome 70.0.3538.110
Reproducible Demo
Here's an example repo
The text was updated successfully, but these errors were encountered: