-
-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve the error message when this
is undefined
#17
Comments
cc @rwjblue this was opened at your suggestion following some chat in octane-migration. |
Hey all. Just came upon this today. Is there a more proper way to access
Am I misinterpreting how this addon should be used? |
@ELepolt You have to use the Example
|
#OctaneWoes. Thank you so much. |
One thing that I've learned here that someone can make use of is In my case, I had to save a reference to a node and solved that by using {{!-- template.hbs --}}
<div {{did-insert this.setFileRef}}>
<div id="selector"></div>
</div> // component.js
import Component from '@glimmer/component';
- import { action } from '@ember/object';
+ import { action, set } from '@ember/object';
export default class SomeComponent extends Component {
@action
setFileRef() {
- this.set('fieldRef', document.querySelector('#selector'));
+ set(this, 'fieldRef', document.querySelector('#selector'));
}
} That might not be the best example because in this case |
@tniezurawski You don't need to use Also, you can do this code differently here. As a modifier passes in the element it's attached to so instead of looking through the whole document you can look just within this component.
|
@dgavey Oh, nice! Thanks for the explanation! |
Anyone have a hint on where I could go about adding this ? |
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
:{{fn}}
uses this error message:The text was updated successfully, but these errors were encountered: