Skip to content

Commit

Permalink
fix: adds null check
Browse files Browse the repository at this point in the history
  • Loading branch information
ahennr committed Mar 11, 2024
1 parent 91639d8 commit 347c624
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/Button/MeasureButton/MeasureButton.tsx
Expand Up @@ -2,6 +2,7 @@ import './MeasureButton.less';

import MeasureUtil from '@terrestris/ol-util/dist/MeasureUtil/MeasureUtil';
import {useMap, useOlInteraction, useOlLayer} from '@terrestris/react-util';
import _isNil from 'lodash/isNil';
import OlCollection from 'ol/Collection';
import {Coordinate as OlCoordinate} from 'ol/coordinate';
import OlFeature from 'ol/Feature';
Expand Down Expand Up @@ -503,8 +504,12 @@ export const MeasureButton: FC<MeasureButtonProps> = ({
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);
}
Expand Down

0 comments on commit 347c624

Please sign in to comment.