score:9

Accepted answer

The public class field syntax (so doSomething = () => {...}) is not yet part of ECMAScript but it is doing well and I am pretty confident that it will get there.

So using this syntax forces you to transpile, but it brings advantages:

  • clear, concise syntax for expressing this binding
  • future proof for when browsers support this
  • not concerned with implementation

For me, this is a clear win. In most cases, you don't even need a constructor(props), saving you from that boilerplate super call.

If the Babel implementation would cause memory leaks, you can be sure those would have been found and fixed quickly. You are more likely to create leaks yourself by having to write more code.

score:0

The link here clearly highlights that officially it's safe to "Bind methods in constructor" rather than using the arrow function as a short code to achieve event binding.

Here is the link: https://reactjs.org/docs/react-without-es6.html#autobinding for reference.


Related Query

More Query from same tag