From 63fd8101f2abde5c549b5c937ca48788803bceb3 Mon Sep 17 00:00:00 2001 From: Sebastian Malton Date: Wed, 17 Mar 2021 08:18:01 -0400 Subject: [PATCH] disposeOnUmount Signed-off-by: Sebastian Malton --- .../components/+preferences/preferences.tsx | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/renderer/components/+preferences/preferences.tsx b/src/renderer/components/+preferences/preferences.tsx index d17f1de8b4..16a931e98a 100644 --- a/src/renderer/components/+preferences/preferences.tsx +++ b/src/renderer/components/+preferences/preferences.tsx @@ -2,7 +2,7 @@ import "./preferences.scss"; import React from "react"; import { computed, observable, reaction } from "mobx"; -import { observer } from "mobx-react"; +import { disposeOnUnmount, observer } from "mobx-react"; import { userStore } from "../../../common/user-store"; import { isWindows } from "../../../common/vars"; @@ -31,12 +31,14 @@ export class Preferences extends React.Component { } componentDidMount() { - reaction(() => navigation.location.hash, hash => { - document.getElementById(hash.slice(1))?.scrollIntoView(); - navigation.location.hash = ""; - }, { - fireImmediately: true - }); + disposeOnUnmount(this, [ + reaction(() => navigation.location.hash, hash => { + document.getElementById(hash.slice(1))?.scrollIntoView(); + navigation.location.hash = ""; + }, { + fireImmediately: true + }) + ]); } render() {