Skip to content

Commit 54667ca

Browse files
committed
fix: structured clone can't be used for all properties of OlFeature
1 parent ee93543 commit 54667ca

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

src/Hooks/useCoordinateInfo/useCoordinateInfo.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import {
22
useCallback, useEffect, useMemo, useRef, useState
33
} from 'react';
44

5+
import _cloneDeep from 'lodash/cloneDeep';
56
import _isNil from 'lodash/isNil';
67
import _isString from 'lodash/isString';
78
import _uniqueId from 'lodash/uniqueId';
@@ -390,8 +391,8 @@ export const useCoordinateInfo = ({
390391
evtPixelCoordinate = [olEvt.originalEvent.x, olEvt.originalEvent.y];
391392
}
392393

393-
const clonedCoordinate = structuredClone(coordinate);
394-
const clonedPixelCoordinate = structuredClone(evtPixelCoordinate ?? pixel);
394+
const clonedCoordinate = _cloneDeep(coordinate);
395+
const clonedPixelCoordinate = _cloneDeep(evtPixelCoordinate ?? pixel);
395396
setClickCoordinate(clonedCoordinate);
396397
setPixelCoordinate(clonedPixelCoordinate);
397398
}, [clickEvent, map, viewProjection, viewResolution]);
@@ -449,7 +450,7 @@ export const useCoordinateInfo = ({
449450
}
450451

451452
const flatResults = allResults.flat();
452-
const clonedResults = structuredClone(flatResults);
453+
const clonedResults = _cloneDeep(flatResults);
453454

454455
setFeatureResults(clonedResults);
455456
onSuccess?.();

0 commit comments

Comments
 (0)