Open yoshuawuyts opened 9 years ago
Does this help? Apparently there should be a destroy
method.
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! :tada:
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.