You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
OK I see thanks! I suppose this would have worked if I used the Component extends React.Component and the new method definition (aka render(){ ... }. Thanks :-)
So the workaround to get this scoped to the parent scope is the old var that = this? That's a shame. Also a shame you can't pass in options with the Babel preset :(
@brendensoares It's not clear what you're asking. I'd recommend dropping by our documented support channels or #javascript on Freenode if you have specific ES6 questions.
Activity
sebmck commentedon Feb 10, 2015
See babel/babel#733. Arrow functions aren't equivalent to normal functions, whenever you use
thisinside them it refers to the outerthis.thom4parisot commentedon Feb 10, 2015
OK I see thanks! I suppose this would have worked if I used the
Component extends React.Componentand the new method definition (akarender(){ ... }. Thanks :-)sebmck commentedon Feb 10, 2015
You can also use the method shorthand syntax inside object literals like so:
thom4parisot commentedon Feb 10, 2015
👍 ah that's great thanks! I did not know it worked for non-class declarations. Thanks :-)
sebmck commentedon Feb 10, 2015
No problem! Happy to answer any questions, feel free to check out our gitter room too.
IngwiePhoenix commentedon Nov 26, 2015
Sorry for butting in all of a sudden :)
I just began using Babel alltogether and realized, that sometimes this:
Would become this:
instead. Namely, the undefined-treatment happens against this line: https://github.com/musictheory/oj/blob/master/src/runtime.js#L375
What is the best way to get rid of that behaviour, altogether?
zertosh commentedon Nov 27, 2015
@IngwiePhoenix That's being done by babel-plugin-transform-es2015-modules-commonjs. It's part of babel-preset-es2015. You can turn off transforming the top level
thistoundefinedby passing it{allowTopLevelThis: true}. Like this:That of course means that you can't use a preset, you'll have to specify the transforms individually so you can pass in that option.
IngwiePhoenix commentedon Nov 27, 2015
Really? How come this won't work with a preset?
2015-11-27 5:30 GMT+01:00 Andres Suarez [email protected]:
zertosh commentedon Nov 27, 2015
Presets don't take options.
brendensuarez commentedon Apr 8, 2016
So the workaround to get
thisscoped to the parent scope is the oldvar that = this? That's a shame. Also a shame you can't pass in options with the Babel preset :(loganfsmyth commentedon Apr 8, 2016
@brendensoares It's not clear what you're asking. I'd recommend dropping by our documented support channels or
#javascripton Freenode if you have specific ES6 questions.