MCPcopy
hub / github.com/facebook/react / recordMount

Function recordMount

packages/react-devtools-shared/src/backend/legacy/renderer.js:386–444  ·  view source on GitHub ↗
(
    internalInstance: InternalInstance,
    id: number,
    parentID: number,
  )

Source from the content-addressed store, hash-verified

384 }
385
386 function recordMount(
387 internalInstance: InternalInstance,
388 id: number,
389 parentID: number,
390 ) {
391 const isRoot = parentID === 0;
392
393 if (__DEBUG__) {
394 console.log(
395 '%crecordMount()',
396 'color: green; font-weight: bold;',
397 id,
398 getData(internalInstance).displayName,
399 );
400 }
401
402 if (isRoot) {
403 // TODO Is this right? For all versions?
404 const hasOwnerMetadata =
405 internalInstance._currentElement != null &&
406 internalInstance._currentElement._owner != null;
407
408 pushOperation(TREE_OPERATION_ADD);
409 pushOperation(id);
410 pushOperation(ElementTypeRoot);
411 pushOperation(0); // StrictMode compliant?
412 pushOperation(0); // Profiling flag
413 pushOperation(0); // StrictMode supported?
414 pushOperation(hasOwnerMetadata ? 1 : 0);
415 pushOperation(supportsTogglingSuspense ? 1 : 0);
416
417 pushOperation(SUSPENSE_TREE_OPERATION_ADD);
418 pushOperation(id);
419 pushOperation(parentID);
420 pushOperation(getStringID(null)); // name
421 // TODO: Measure rect of root
422 pushOperation(-1);
423 } else {
424 const type = getElementType(internalInstance);
425 const {displayName, key} = getData(internalInstance);
426
427 const ownerID =
428 internalInstance._currentElement != null &&
429 internalInstance._currentElement._owner != null
430 ? getID(internalInstance._currentElement._owner)
431 : 0;
432
433 const displayNameStringID = getStringID(displayName);
434 const keyStringID = getStringID(key);
435 pushOperation(TREE_OPERATION_ADD);
436 pushOperation(id);
437 pushOperation(type);
438 pushOperation(parentID);
439 pushOperation(ownerID);
440 pushOperation(displayNameStringID);
441 pushOperation(keyStringID);
442 pushOperation(getStringID(null)); // name prop
443 }

Callers 2

mountComponentFunction · 0.70

Calls 5

getElementTypeFunction · 0.85
getIDFunction · 0.85
getDataFunction · 0.70
pushOperationFunction · 0.70
getStringIDFunction · 0.70

Tested by

no test coverage detected