diff options
-rw-r--r-- | src/components/SponsorTimeEditComponent.tsx | 13 |
1 files changed, 12 insertions, 1 deletions
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<SponsorTimeEditProps, Spo categoryOptionRef: React.RefObject<HTMLSelectElement>; + configUpdateListener: () => void; + constructor(props: SponsorTimeEditProps) { super(props); @@ -49,7 +51,16 @@ class SponsorTimeEditComponent extends React.Component<SponsorTimeEditProps, Spo }); // Add as a config listener - Config.configListeners.push(this.configUpdate.bind(this)); + if (!this.configUpdateListener) { + this.configUpdateListener = () => this.configUpdate(); + Config.configListeners.push(this.configUpdate.bind(this)); + } + } + + componentWillUnmount() { + if (this.configUpdateListener) { + Config.configListeners.splice(Config.configListeners.indexOf(this.configUpdate.bind(this))); + } } render() { |