MCPcopy
hub / github.com/QwikDev/qwik / executeComponent

Function executeComponent

packages/qwik/src/core/render/execute-component.ts:28–103  ·  view source on GitHub ↗
(
  rCtx: RenderContext,
  elCtx: QContext,
  attempt?: number
)

Source from the content-addressed store, hash-verified

26}
27
28export const executeComponent = (
29 rCtx: RenderContext,
30 elCtx: QContext,
31 attempt?: number
32): ValueOrPromise<ExecuteComponentOutput> => {
33 elCtx.$flags$ &= ~HOST_FLAG_DIRTY;
34 elCtx.$flags$ |= HOST_FLAG_MOUNTED;
35 elCtx.$slots$ = [];
36 elCtx.li.length = 0;
37
38 const hostElement = elCtx.$element$;
39 const componentQRL = elCtx.$componentQrl$;
40 const props = elCtx.$props$;
41 const iCtx = newInvokeContext(rCtx.$static$.$locale$, hostElement, undefined, RenderEvent);
42 const waitOn: Promise<unknown>[] = (iCtx.$waitOn$ = []);
43 assertDefined(componentQRL, `render: host element to render must have a $renderQrl$:`, elCtx);
44 assertDefined(props, `render: host element to render must have defined props`, elCtx);
45
46 // Set component context
47 const newCtx = pushRenderContext(rCtx);
48 newCtx.$cmpCtx$ = elCtx;
49 newCtx.$slotCtx$ = undefined;
50
51 // Invoke render hook
52 iCtx.$subscriber$ = [0, hostElement];
53 iCtx.$renderCtx$ = rCtx;
54
55 // Resolve render function
56 componentQRL.$setContainer$(rCtx.$static$.$containerState$.$containerEl$);
57 const componentFn = componentQRL.getFn(iCtx);
58
59 return safeCall(
60 () => componentFn(props),
61 (jsxNode) => {
62 return maybeThen(
63 isServerPlatform()
64 ? maybeThen(promiseAllLazy(waitOn), () =>
65 // Run dirty tasks before SSR output is generated.
66 maybeThen(executeSSRTasks(rCtx.$static$.$containerState$, rCtx), () =>
67 promiseAllLazy(waitOn)
68 )
69 )
70 : promiseAllLazy(waitOn),
71 () => {
72 if (elCtx.$flags$ & HOST_FLAG_DIRTY) {
73 if (attempt && attempt > 100) {
74 logWarn(`Infinite loop detected. Element: ${elCtx.$componentQrl$?.$symbol$}`);
75 } else {
76 return executeComponent(rCtx, elCtx, attempt ? attempt + 1 : 1);
77 }
78 }
79 return {
80 node: jsxNode,
81 rCtx: newCtx,
82 };
83 }
84 );
85 },

Callers 2

renderComponentFunction · 0.90
renderSSRComponentFunction · 0.90

Calls 10

newInvokeContextFunction · 0.90
assertDefinedFunction · 0.90
safeCallFunction · 0.90
maybeThenFunction · 0.90
isServerPlatformFunction · 0.90
promiseAllLazyFunction · 0.90
executeSSRTasksFunction · 0.90
logWarnFunction · 0.90
handleErrorFunction · 0.90
pushRenderContextFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…