Should not use Arrow functionsJS-0774
ember
Arrow functions should not be used in computed properties because they are unable to access other properties (using this.property) of the same object. Accidental usage can thus lead to bugs.
Bad Practice
import EmberObject, { computed } from '@ember/object';
const Person = EmberObject.extend({
fullName: computed('firstName', 'lastName', () => {
return `${this.firstName} ${this.lastName}`;
})
});
Recommended
import EmberObject, { computed } from '@ember/object';
const Person = EmberObject.extend({
fullName: computed('firstName', 'lastName', function () {
return `${this.firstName} ${this.lastName}`;
})
});