« All deprecation guides
Deprecation Guide for
Deprecate setting properties on objects generated by
Deprecation Guide for
Deprecate setting properties on objects generated by {{hash}}
until: 4.4.0
id: setting-on-hash
Objects generated by {{hash}}
helper method no longer supports setting properties because it was defined on the original hash and is a reference to the original value. Objects generated by {{hash}}
can be considered immutable as internally it returns a Proxy object rather than an original object. You can get the same functionality by using an object created with a tracked property or getter, or with a custom helper.
Before:
<Greeting @person={{hash firstName='Christian' lastName='Bale'}} />
app/components/greeting.js
export default class GreetingComponent extends Component {
constructor() {
super(...arguments);
const person = this.args.person;
person.firstName = 'Bruce';
person.lastName = 'Wayne';
}
}
Hello, {{@person.firstName}} {{@person.lastName}}
{{!-- Hello, Christian Bale --}}
After:
<Greeting @person={{this.person}} />
app/controllers/application.js
export default class ApplicationController extends Controller {
@tracked person = {
firstName: 'Christian',
lastName: 'Bale',
};
}
Hello, {{@person.firstName}} {{@person.lastName}}
{{!-- Hello, Bruce Wayne --}}