Re:How I converted my React app to VanillaJS
by teniutza on Monday January 02, 2017 @06:30AM
(#13300546)
It Uses "fat arrow" functions (lambdas) to define function. It is "equivalent" (there are several differences here, like "const" and the context of the function) to:
Edited to reflect the valid point brought up in the comments
[ Parent
| on HN ]
Re:How I converted my React app to VanillaJS
by drdaeman on Monday January 02, 2017 @07:28AM
(#13300767)
Not really an equivalent, because "this" would be different - unlike with function(){}, there is no automatic this-context binding with arrows, so just switching to a fancier syntax in existing code may break things.
Also, no "arguments" (there are ...rest parameters that allow for variadic functions).
Re:How I converted my React app to VanillaJS
by divbit on Monday January 02, 2017 @11:25AM
(#13302034)
> no automatic this-context binding with arrows,
I thought the arrows were now binding to surrounding context? (e.g. https://babeljs.io/blog/2015/06/07/react-on-es6-plus)
Re:How I converted my React app to VanillaJS
by nicoburns on Monday January 02, 2017 @11:30AM
(#13302084)
It is equivalent in this case though, as the function body doesn't use any of those features...
Re:How I converted my React app to VanillaJS
by closetnerd on Monday January 02, 2017 @06:56AM
(#13300627)
Techinically you're missing a return.