-
Notifications
You must be signed in to change notification settings - Fork 800
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
Abnormal behavior with arrow function class methods caused by RHL #428
Comments
I think this is another instance of #313. Try adding either |
That means transpiling ES6 to ES5, which seems like a temporary fix, as there shouldn't be need for such transpilation, although it doesn't matter much either as it happens only in dev mode. I was able to get the code working by adding transform-class-properties and transform-es2015-classes (the plugins have to be in correct loading order also):
|
Right, that's why it's an open issue, and adding the transform is a workaround. 😉 |
Anyway, thanks for quick reply. Spent so many hours today trying to find solution. Also I don't mind the workaround as it doesn't affect the production bundle. Hope you can find solution (the issue seems to have been open already 4 months ;)) |
Problem: RHL causes Components with arrow function class methods to behave abnormally.
First, here's my .babelrc:
, and here's the code:
I found two fixes: either remove "react-hot-loader/babel" from Babel plugins, or changing
show
from arrow class method to ordinary class method and adding manual binding of this:I originally posted the issue to StackOverflow, but after realizing the connection to RHL, I figured out this is more approriate place to find answers.
So, is the behavior a bug of RHL, because it does seem like so? How about fix?
I have an example app that can be used for reproducing the issue. Just embed the component above for example into index.jsx.
The text was updated successfully, but these errors were encountered: