MCPcopy Create free account
hub / github.com/RobPruzan/react-scratch / buildReactTrees

Function buildReactTrees

src/react/core.ts:1317–1377  ·  view source on GitHub ↗
(
  rootComponentInternalMetadata: ReactComponentInternalMetadata
)

Source from the content-addressed store, hash-verified

1315}
1316
1317export const buildReactTrees = (
1318 rootComponentInternalMetadata: ReactComponentInternalMetadata
1319) => {
1320 const rootRenderTreeNode: ReactRenderTreeNode =
1321 rootComponentInternalMetadata.kind === "empty-slot"
1322 ? {
1323 kind: "empty-slot",
1324 parent: null,
1325 }
1326 : // this looks super weird, but we transform the root metadata into an implicit
1327 // component that returns the provided internal metadata
1328 {
1329 kind: "real-element",
1330 childNodes: [],
1331 computedViewTreeNodeId: null,
1332 hasRendered: false,
1333 hooks: [],
1334 id: crypto.randomUUID(),
1335 indexPath: [],
1336 internalMetadata: {
1337 component: {
1338 kind: "function",
1339 function: () => rootComponentInternalMetadata,
1340 name: "root",
1341 },
1342 children: [],
1343 id: crypto.randomUUID(),
1344 kind: "real-element",
1345 props: null,
1346 provider: null,
1347 // parent: null
1348 },
1349 parent: null,
1350 };
1351
1352 currentTreeRef.renderTree = {
1353 root: rootRenderTreeNode,
1354 currentLastRenderChildNodes: [],
1355 currentLocalCurrentHookOrder: 0,
1356 currentlyRendering: null,
1357 };
1358
1359 console.log("\n\nRENDER START----------------------------------------------");
1360 const output = generateViewTree({
1361 renderNode: rootRenderTreeNode,
1362 parentViewNode: null,
1363 });
1364
1365 console.log("RENDER END----------------------------------------------\n\n");
1366 const reactViewTree: ReactViewTree = {
1367 root: output,
1368 };
1369
1370 currentTreeRef.viewTree = reactViewTree;
1371 currentTreeRef.renderTree.currentlyRendering = null;
1372
1373 return {
1374 reactRenderTree: currentTreeRef.renderTree,

Callers 1

renderFunction · 0.85

Calls 1

generateViewTreeFunction · 0.85

Tested by

no test coverage detected