import { useMapEvent } from 'react-leaflet'
import { LatLng } from 'leaflet'

import { SetState } from '../utils/types'

function MapClickHandler({ setPosition }: { setPosition: SetState<LatLng> }) {
    const map = useMapEvent('click', (e) => {
        setPosition(e.latlng)
        map.setView(e.latlng)
    })

    return null
}

export default MapClickHandler
