SPFx webpart onBeforeDelete?
-
08-12-2020 - |
题
I need the ability to perform file cleanup when a client-side web part is deleted from the page. How can I listen for the delete event?
解决方案
You should override the Dispose() method on BaseClientSideWebPart. Make sure you call the base implementation as well.
protected dispose(): void
{
// Do something interesting
Log.warn("HelloWorld", "Cleaning up my stuff", this.context.serviceScope);
// call the base class.
super.dispose();
}
Note however, there there is a currently a bug where this code doesn't necessarily get called. That will be fixed.