From 2f842a0455698d49fc1328d6d0264ba134494d07 Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Sun, 10 May 2020 20:32:49 -0400 Subject: [PATCH] Remove config listener from EditComponent properly --- src/components/SponsorTimeEditComponent.tsx | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/components/SponsorTimeEditComponent.tsx b/src/components/SponsorTimeEditComponent.tsx index 07f20cba..e67f9d65 100644 --- a/src/components/SponsorTimeEditComponent.tsx +++ b/src/components/SponsorTimeEditComponent.tsx @@ -29,6 +29,8 @@ class SponsorTimeEditComponent extends React.Component; + configUpdateListener: () => void; + constructor(props: SponsorTimeEditProps) { super(props); @@ -49,7 +51,16 @@ class SponsorTimeEditComponent extends React.Component this.configUpdate(); + Config.configListeners.push(this.configUpdate.bind(this)); + } + } + + componentWillUnmount() { + if (this.configUpdateListener) { + Config.configListeners.splice(Config.configListeners.indexOf(this.configUpdate.bind(this))); + } } render() {