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

Function createDivOverlayComponent

packages/core/src/component.tsx:39–64  ·  view source on GitHub ↗
(useElement: ReturnType<DivOverlayHook<E, PropsWithoutRef<P>>>)

Source from the content-addressed store, hash-verified

37}
38
39export function createDivOverlayComponent<
40 E extends DivOverlay,
41 P extends PropsWithChildren,
42>(useElement: ReturnType<DivOverlayHook<E, PropsWithoutRef<P>>>) {
43 function OverlayComponent(props: PropsWithoutRef<P>, forwardedRef: Ref<E>) {
44 const [isOpen, setOpen] = useState(false)
45 const { instance } = useElement(props, setOpen).current
46
47 useImperativeHandle(forwardedRef, () => instance)
48 // biome-ignore lint/correctness/useExhaustiveDependencies: update overlay when children change
49 useEffect(
50 function updateOverlay() {
51 if (isOpen) {
52 instance.update()
53 }
54 },
55 [instance, isOpen, props.children],
56 )
57
58 // @ts-ignore _contentNode missing in type definition
59 const contentNode = instance._contentNode
60 return contentNode ? createPortal(props.children, contentNode) : null
61 }
62
63 return forwardRef(OverlayComponent)
64}
65
66export function createLeafComponent<E, P>(
67 useElement: ElementHook<E, PropsWithoutRef<P>>,

Callers 2

components.tsxFile · 0.90
createOverlayComponentFunction · 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…