Skip to content

Build your personal knowledge base with Trilium Notes

chore(react/collections/geomap): properly dispose

Elian Doran8bb8e011f330
diff --git a/apps/client/src/widgets/collections/geomap/map.tsx b/apps/client/src/widgets/collections/geomap/map.tsx
index bb4f22c03e..6e1cb57f1d 100644
--- a/apps/client/src/widgets/collections/geomap/map.tsx
+++ b/apps/client/src/widgets/collections/geomap/map.tsx
@@ -23,9 +23,15 @@ export default function Map({ coordinates, zoom, layerName, viewportChanged, chi
useEffect(() => {
if (!containerRef.current) return;
- mapRef.current = L.map(containerRef.current, {
+ const mapInstance = L.map(containerRef.current, {
worldCopyJump: true
});
+
+ mapRef.current = mapInstance;
+ return () => {
+ mapInstance.off();
+ mapInstance.remove();
+ };
}, []);
// Load the layer asynchronously.