Skip to content

Commit

Permalink
fix: adds dependency and handler variable to use in cleanup function
Browse files Browse the repository at this point in the history
  • Loading branch information
mholthausen committed Sep 19, 2024
1 parent 296955c commit 325c153
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/Panel/TimeLayerSliderPanel/TimeLayerSliderPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export const TimeLayerSliderPanel: React.FC<TimeLayerSliderPanelProps> = memo(
setCurrentValue(initEndDate);
setEndDate(initEndDate);
wmsTimeHandler(initEndDate);
}, []);
}, [initEndDate]);

const onPlaybackSpeedChange = useCallback(
(val: number | PlaybackSpeedType) => {
Expand Down Expand Up @@ -170,8 +170,10 @@ export const TimeLayerSliderPanel: React.FC<TimeLayerSliderPanelProps> = memo(
);

useEffect(() => {
const handler = debouncedWmsTimeHandlerRef.current;

return () => {
debouncedWmsTimeHandlerRef.current.cancel();
handler.cancel();
};
}, []);

Expand Down

0 comments on commit 325c153

Please sign in to comment.