From 5a78b7736881da8d4970dca1673de16c55bff938 Mon Sep 17 00:00:00 2001 From: Andre Henn Date: Mon, 11 Mar 2024 10:56:02 +0100 Subject: [PATCH] fix: adds null check --- src/Button/MeasureButton/MeasureButton.tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Button/MeasureButton/MeasureButton.tsx b/src/Button/MeasureButton/MeasureButton.tsx index 6f19c3b65..436da652c 100644 --- a/src/Button/MeasureButton/MeasureButton.tsx +++ b/src/Button/MeasureButton/MeasureButton.tsx @@ -517,8 +517,12 @@ export const MeasureButton: FC = ({ const onMapClickKey = map?.on('click', onMapClick); return () => { - unByKey(onDrawStartKey); - unByKey(onDrawEndKey); + if (!_isNil(onDrawStartKey)) { + unByKey(onDrawStartKey); + } + if (!_isNil(onDrawEndKey)) { + unByKey(onDrawEndKey); + } if (onMapPointerMoveKey) { unByKey(onMapPointerMoveKey); }