diff --git a/src/PluginContainer.js b/src/PluginContainer.js index 126d7ba8c..ae06f88dc 100644 --- a/src/PluginContainer.js +++ b/src/PluginContainer.js @@ -79,6 +79,13 @@ class PluginContainer extends PureComponent { } }; + componentWillUnmount() { + if (this.plugin) { + this.plugin._teardown(); + this.plugin = null; + } + } + render() { const { pluginState, diff --git a/src/plugin.js b/src/plugin.js index db250e8aa..e640827d5 100644 --- a/src/plugin.js +++ b/src/plugin.js @@ -164,6 +164,10 @@ export class FlipperDevicePlugin extends FlipperBasePlugin< this.init(); } + _teardown() { + this.teardown(); + } + static supportsDevice(device: BaseDevice) { throw new Error( 'supportsDevice is unimplemented in FlipperDevicePlugin class',