I've never had a linter complain about number 3. I'll usually go for 4 but if I'm doing something like a console.log() for debugging or data tracking I'll use 3 no problem.
Also 3 and 4 are the only ways to implicitly bind a function expression in react without having to manually call this.function = this.function.bind(this)
Every time I’ve tried to use fat arrow functions like this, I get a syntax error. At least the first few times I looked at the error (briefly) it was about “experimental syntax” not being turned on — any idea what I’m missing?
Okay... but I’m using Babel with webpack to transpire my code. Is there a specific preset I need, looks like ‘stage-0’ perhaps? Or plugins like ‘transform-decorators-legacy’?
2
u/noruthwhatsoever Dec 18 '18
I've never had a linter complain about number 3. I'll usually go for 4 but if I'm doing something like a
console.log()for debugging or data tracking I'll use 3 no problem.Also 3 and 4 are the only ways to implicitly bind a function expression in react without having to manually call
this.function = this.function.bind(this)