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

Function useLayerLifecycle

packages/core/src/layer.ts:15–31  ·  view source on GitHub ↗
(
  element: LeafletElement<Layer>,
  context: LeafletContextInterface,
)

Source from the content-addressed store, hash-verified

13 InteractiveLayerOptions {}
14
15export function useLayerLifecycle(
16 element: LeafletElement<Layer>,
17 context: LeafletContextInterface,
18) {
19 useEffect(
20 function addLayer() {
21 const container = context.layerContainer ?? context.map
22 container.addLayer(element.instance)
23
24 return function removeLayer() {
25 context.layerContainer?.removeLayer(element.instance)
26 context.map.removeLayer(element.instance)
27 }
28 },
29 [context, element],
30 )
31}
32
33export function createLayerHook<E extends Layer, P extends LayerProps>(
34 useElement: ElementHook<E, P>,

Callers 3

layer.tsFile · 0.90
createPathHookFunction · 0.85
createLayerHookFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…