SPFx webpart onBeforeDelete?
-
08-12-2020 - |
Question
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?
Solution
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.
Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange