fix: add unregister mechanism for map icon updates to prevent memory leaks during component unmount

This commit is contained in:
taDuc
2026-05-26 17:16:39 +07:00
parent 2a3193a3fa
commit cdf3323d77
3 changed files with 7 additions and 1 deletions
+2
View File
@@ -3,6 +3,7 @@ import maplibregl from "maplibre-gl";
import { MAP_MAX_ZOOM, MAP_MIN_ZOOM } from "@/uhm/lib/map/constants";
import { clampNumber, roundZoom } from "./mapUtils";
import { getBaseMapStyle } from "./useMapLayers";
import { unregisterMapFromIconUpdates } from "@/uhm/lib/map/styles/geotypeLayers";
const MAP_PROJECTION_STORAGE_KEY = "uhm:mapProjection";
@@ -79,6 +80,7 @@ export function useMapInstance() {
if (mapRef.current === map) {
mapRef.current = null;
}
unregisterMapFromIconUpdates(map);
map.remove();
};
} catch (err) {