MCPcopy
hub / github.com/PaulLeCam/react-leaflet / useMapEvent

Function useMapEvent

packages/react-leaflet/src/hooks.ts:9–29  ·  view source on GitHub ↗
(
  type: T,
  handler: LeafletEventHandlerFnMap[T],
)

Source from the content-addressed store, hash-verified

7}
8
9export function useMapEvent<T extends keyof LeafletEventHandlerFnMap>(
10 type: T,
11 handler: LeafletEventHandlerFnMap[T],
12): LeafletMap {
13 const map = useMap()
14
15 useEffect(
16 function addMapEventHandler() {
17 // @ts-ignore event type
18 map.on(type, handler)
19
20 return function removeMapEventHandler() {
21 // @ts-ignore event type
22 map.off(type, handler)
23 }
24 },
25 [map, type, handler],
26 )
27
28 return map
29}
30
31export function useMapEvents(handlers: LeafletEventHandlerFnMap): LeafletMap {
32 const map = useMap()

Callers

nothing calls this directly

Calls 1

useMapFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…