-
-
Notifications
You must be signed in to change notification settings - Fork 33
Improve the error message when this is undefined #17
Copy link
Copy link
Open
Description
If you try to use this within methods called by {{on}} and {{fn}}, they show a helpful error instructing the developer to use the @action decorator. The render modifiers could show something like that too.
Here's an example "error" use case for did-insert:
<div class="my-container" {{did-insert this.renderEditor}}></div>
import Component from '@glimmer/component';
export default class CodeEditor extends Component {
renderEditor(el) {
console.log(this.args.code)
}
}
TypeError: this is undefined
{{fn}} uses this error message:
You accessed
this.arg2from a function passed to thefnhelper, but the function itself was not bound to a validthiscontext. Consider updating to usage of@action.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels