-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
component.get() can return undefined after component destroyed #1354
Comments
Related: it would be useful to be able to know within an asynchronous callback whether the component was destroyed or not, without having to attach an |
Can we combine these two problems into a solution? Does |
I'm not sure. What I am sure about is that if the component is destroyed, then In any case, I would prefer not to have to think about every place in my code where the component might have been destroyed (i.e. to wrap |
I also just fell into this. |
set state to blank object on destroy, not null
As of 2.1.1, component |
Since
this.get('foo')
is deprecated (#1347), I've been working on migrating all usages tolet { foo } = this.get()
.However I've found that the two aren't exactly equivalent, since
this.get()
can actually returnundefined
if the component is destroyed (e.g. because it was called within arequestIdleCallback()
orsetTimeout()
callback).Throws an error:
Doesn't throw an error:
So far, my workaround has been to do
let { foo } = this.get() || {}
but it would be nice if it were just automatically wrapped in an empty object so that the two forms were equivalent.The text was updated successfully, but these errors were encountered: