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
Arrow-function default parameter not behaving as expected in MS Edge #8759
Comments
Hey @Floriferous! We really appreciate you taking the time to report an issue. The collaborators If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack |
I don't have MS Edge so I can't reproduce it, but
|
Just encountered the same problem on Edge 17 (seemed to work on 18). Writing a function like this: class MyComponent extends React.Component {
myFunc = (param = 'myValue') => {
console.log(this); // undefined in Edge 17
[...]
}
} transpiles to a normal function instead of an arrow function function () {
let param = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
[...]
} |
Could you post the full output for this code? class MyComponent extends React.Component {
myFunc = (param = 'myValue') => {
console.log(this); // undefined in Edge 17
}
} I get this correct output: class MyComponent extends React.Component {
constructor() {
var _this;
super(...arguments);
_this = this;
_defineProperty(this, "myFunc", function () {
let param = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'myValue';
console.log(_this); // undefined in Edge 17
});
}
} |
Is this potentially fixed in #8019? It could be the same issue where |
This is what I get: class MyComponent extends React.Component {
constructor() {
var _this;
_this = super(...arguments);;
_defineProperty(this, "myFunc", function () {
let param = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'myValue';
console.log(_this); // undefined in Edge 17
});
}
} |
I am not entirely sure since I use Meteor v1.8... |
You can check it by running |
Thanks! |
That shouldn't affect it 🤔 |
@tducasse Is this still an issue? |
I have solved my problem by simply removing the arrow function that was causing it. Not sure it's still a problem, so feel free to close the issue 👍 |
Ok, I'm closing this since it should be fixed by #8019 👍 |
Bug Report
This React code here does not work on MS Edge, but does work on other browsers I tested (Chrome, Safari, Firefox):
Here's a reproduction in a meteor app: https://github.com/Floriferous/ms-edge-arrow-default-param
Here's the .babelrc:
The checkState arrow function is transformed into a function, because of the unsupported default param (I guess). And so
this
is not defined whencheckState
is called in the callback.The text was updated successfully, but these errors were encountered: