re: State Vs Prop / Arrow Functions in React VIEW POST

re: Avoid using arrow functions inside React components. They are helpful! We don't have to bind our methods in the constructor in order to use the t...

Some time ago I read a comment by a Polymer dev, that const arrows are faster.



I will have to disagree that arrow functions are faster than "normal" functions.
Arrow functions are just wrappers (syntactical sugar) of "normal" functions.

Even if they weren't, what we should not forget is that for production apps, es6 gets transpiled to es5 (most of the time).

// in the end this:
const thing = () => console.log('aha!');

//becomes this:
var thing = function thing() {
  return console.log('aha!');

However I like arrow functions, I dislike the fact that when transpiled, we end up with a variable x that references a function named x.
Now if we want to pass x to y, we will end up with y referencing x (the variable) that references x (the function). What a mess, right?

Why not just have a function x in the first place?

code of conduct - report abuse