You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jun 16, 2020. It is now read-only.
When building a widget only init and update hooks are exposed. How do I know when a Node is destroyed so I can clean up elements?
I can check if a node is removed by doing in update if (prev.parentNode === null), but that feels somewhat dirty. I was wondering if there's a better way (e.g. using hooks perhaps?) Thanks!
edit: I'm not even sure if update() is called once an element has been unmounted, thus rendering the check moot. A pointer in the right direction would be much appreciated.
The text was updated successfully, but these errors were encountered:
yoshuawuyts
changed the title
question: how to clean up unmount hooks for widgets
question: how to detect if a widget has been unmounted
Oct 4, 2015
Ah, yes that is exactly what I was looking for. It wasn't showing up in the other docs. I'll update my https://github.com/yoshuawuyts/virtual-widget package to include this method. Thanks! 🎉
When building a widget only
init
andupdate
hooks are exposed. How do I know when a Node is destroyed so I can clean up elements?I can check if a node is removed by doing in update
if (prev.parentNode === null)
, but that feels somewhat dirty. I was wondering if there's a better way (e.g. using hooks perhaps?) Thanks!edit: I'm not even sure if
update()
is called once an element has been unmounted, thus rendering the check moot. A pointer in the right direction would be much appreciated.The text was updated successfully, but these errors were encountered: