MCPcopy Index your code
hub / github.com/ionic-team/ionic-framework / attachViewToDom

Function attachViewToDom

packages/react/src/framework-delegate.tsx:19–38  ·  view source on GitHub ↗
(
    parentElement: HTMLElement,
    component: ReactComponent,
    propsOrDataObj?: any,
    cssClasses?: string[]
  )

Source from the content-addressed store, hash-verified

17 let id = 0;
18
19 const attachViewToDom = async (
20 parentElement: HTMLElement,
21 component: ReactComponent,
22 propsOrDataObj?: any,
23 cssClasses?: string[]
24 ): Promise<any> => {
25 const div = document.createElement('div');
26 cssClasses && div.classList.add(...cssClasses);
27 parentElement.appendChild(div);
28
29 const componentWithProps = component(propsOrDataObj);
30 const key = `${reactDelegateId}-${id++}`;
31 const hostComponent = createPortal(componentWithProps, div, key);
32
33 refMap.set(div, hostComponent);
34
35 addView(hostComponent);
36
37 return Promise.resolve(div);
38 };
39
40 const removeViewFromDom = (_container: any, component: HTMLElement): Promise<void> => {
41 const hostComponent = refMap.get(component);

Callers

nothing calls this directly

Calls 4

componentFunction · 0.85
setMethod · 0.80
addViewFunction · 0.50
addMethod · 0.45

Tested by

no test coverage detected