import 'leaflet/dist/leaflet.css'; import leaflet from 'leaflet'; import { useEffect, useRef } from 'preact/hooks'; export const MapComponent = () => { const mapContainerRef = useRef(null); const mapRef = useRef(undefined); useEffect(() => { if (mapRef.current) { return; } if (!mapContainerRef.current) { return; } const map = leaflet.map(mapContainerRef.current); map.setView([51.505, -0.09], 13); leaflet .tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', { maxZoom: 19, attribution: '© OpenStreetMap', }) .addTo(map); mapRef.current = map; }); return
; };