DEV Community

Discussion on: React - ES6 tricks in Classes

Collapse
 
christfriedbalizou profile image
Christfried

Arrow functions is evil. It's just adding more complication reading js code those days. I'll stick to constructor. However it's not old because you use arrow functions. Function != Arrows functions.

Collapse
 
kozakrisz profile image
Krisztian Kecskes

I understand, but disagree. Arrow functions are good friends in nowadays.

Collapse
 
kayis profile image
K

I think function is like var only to be used in legacy cases.

let, const and => are much more predictable.

Collapse
 
rkichenama profile image
Richard Kichenama

Using arrow functions for members defined that way allows for this to remain scoped to the instance of the class / object. It is possible to define it as handleChange = function () { ... }, but then you would need the constructor to bind handleChange to the instance.