From aca6f92fe262b4a102c13d819c642f9bd716345d Mon Sep 17 00:00:00 2001 From: Hanbyul Jo Date: Wed, 25 Sep 2024 09:41:56 -0400 Subject: [PATCH] Clean up the themed controls when unmounted --- .../common/map/controls/hooks/use-themed-control.tsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/scripts/components/common/map/controls/hooks/use-themed-control.tsx b/app/scripts/components/common/map/controls/hooks/use-themed-control.tsx index ff50f88a6..40149bc2e 100644 --- a/app/scripts/components/common/map/controls/hooks/use-themed-control.tsx +++ b/app/scripts/components/common/map/controls/hooks/use-themed-control.tsx @@ -49,6 +49,10 @@ export default function useThemedControl( {renderFn() as any} ); } + return () => { + rootRef.current?.unmount(); + rootRef.current = null; + }; }, [renderFn, theme]); useControl(() => new ThemedControl(), opts);