import React, { FC, useState, useEffect } from 'react'; import { LatLngLiteral, marker, Marker, DivIcon } from 'leaflet'; import { MainMap } from '~/constants/map'; interface IProps { location: LatLngLiteral; } const CurrentLocation: FC = ({ location }) => { useEffect(() => { if (!location) return; const item = new Marker(location, { icon: new DivIcon({ html: `
`, }), }).addTo(MainMap); return () => item.removeFrom(MainMap); }, [MainMap, location]); return null; }; export { CurrentLocation };