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
react-hot-loader/babel creates invalid code with async arrow functions #370
Comments
Correction: this happens even with the |
JUST SPENT 6 HOURS TRYING TO SOLVE THIS 😭 (not yelling at anyone just expressing relief that i finally located the issue) |
😞 That's no good! Sorry @jquense! It makes sense that this would happen in |
I think it should be a straight forward fix, test case: actual class Foo {
bar = async (a, b) => {
return await a(b);
};
} expected var _this = this;
class Foo {
bar = async (...params) => await _this.__bar__REACT_HOT_LOADER__(...params);
async __bar__REACT_HOT_LOADER__(a, b) {
return await a(b);
}
}
;
(function () {
if (typeof __REACT_HOT_LOADER__ === 'undefined') {
return;
}
__REACT_HOT_LOADER__.register(Foo, "Foo", __FILENAME__);
})();
; |
@jquense Awesome, thanks! |
Out in |
webpack 2, 3.0.0-beta.5 'this' context lost in async arrow functions; name = async () => { |
seems like that would be true for any class prop function? I wonder why... |
On a class (that is not a React component), there is a method defined through an arrow function:
Without the es2015 preset (only stage-2, react, and react-hot-loader/babel), this gets transformed to:
This creates an
await
statement not inside anasync
function, which is invalid syntax.This happens with
beta.4
, but rolling back to (the previously working?)beta.3
does not seem to help.The text was updated successfully, but these errors were encountered: