From 325c153381202e727f3c029c31d1bb6081b883d1 Mon Sep 17 00:00:00 2001 From: Michael Holthausen Date: Thu, 19 Sep 2024 11:44:45 +0200 Subject: [PATCH] fix: adds dependency and handler variable to use in cleanup function --- src/Panel/TimeLayerSliderPanel/TimeLayerSliderPanel.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Panel/TimeLayerSliderPanel/TimeLayerSliderPanel.tsx b/src/Panel/TimeLayerSliderPanel/TimeLayerSliderPanel.tsx index e4f5a6e37..39ac77ed5 100644 --- a/src/Panel/TimeLayerSliderPanel/TimeLayerSliderPanel.tsx +++ b/src/Panel/TimeLayerSliderPanel/TimeLayerSliderPanel.tsx @@ -127,7 +127,7 @@ export const TimeLayerSliderPanel: React.FC = memo( setCurrentValue(initEndDate); setEndDate(initEndDate); wmsTimeHandler(initEndDate); - }, []); + }, [initEndDate]); const onPlaybackSpeedChange = useCallback( (val: number | PlaybackSpeedType) => { @@ -170,8 +170,10 @@ export const TimeLayerSliderPanel: React.FC = memo( ); useEffect(() => { + const handler = debouncedWmsTimeHandlerRef.current; + return () => { - debouncedWmsTimeHandlerRef.current.cancel(); + handler.cancel(); }; }, []);