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?

Était-ce utile?

La 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.

Licencié sous: CC-BY-SA avec attribution
Non affilié à sharepoint.stackexchange
scroll top