From 5beb4f7b2bfb98dbf746f67c2f147c2556fd3ade Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zolt=C3=A1n=20Gili=C3=A1n?= Date: Wed, 24 Jul 2019 02:59:05 -0700 Subject: [PATCH] Call plugin teardown method when plugin is destroyed Summary: `teardown()` was not called for device plugins. This diff fixes the issue. Reviewed By: jknoxville Differential Revision: D16416440 fbshipit-source-id: 5c9ffa211bfbe4e322504c37b95ff87afab8d061 --- src/PluginContainer.js | 7 +++++++ src/plugin.js | 4 ++++ 2 files changed, 11 insertions(+) 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',