MCPcopy Index your code
hub / github.com/react/react / inspectElement

Function inspectElement

packages/react-devtools-shared/src/backend/legacy/renderer.js:742–794  ·  view source on GitHub ↗
(
    requestID: number,
    id: number,
    path: Array<string | number> | null,
    forceFullData: boolean,
  )

Source from the content-addressed store, hash-verified

740 }
741
742 function inspectElement(
743 requestID: number,
744 id: number,
745 path: Array<string | number> | null,
746 forceFullData: boolean,
747 ): InspectedElementPayload {
748 if (forceFullData || currentlyInspectedElementID !== id) {
749 currentlyInspectedElementID = id;
750 currentlyInspectedPaths = {};
751 }
752
753 const inspectedElement = inspectElementRaw(id);
754 if (inspectedElement === null) {
755 return {
756 id,
757 responseID: requestID,
758 type: 'not-found',
759 };
760 }
761
762 if (path !== null) {
763 mergeInspectedPaths(path);
764 }
765
766 // Any time an inspected element has an update,
767 // we should update the selected $r value as wel.
768 // Do this before dehydration (cleanForBridge).
769 updateSelectedElement(id);
770
771 inspectedElement.context = cleanForBridge(
772 inspectedElement.context,
773 createIsPathAllowed('context'),
774 );
775 inspectedElement.props = cleanForBridge(
776 inspectedElement.props,
777 createIsPathAllowed('props'),
778 );
779 inspectedElement.state = cleanForBridge(
780 inspectedElement.state,
781 createIsPathAllowed('state'),
782 );
783 inspectedElement.suspendedBy = cleanForBridge(
784 inspectedElement.suspendedBy,
785 createIsPathAllowed('suspendedBy'),
786 );
787
788 return {
789 id,
790 responseID: requestID,
791 type: 'full-data',
792 value: inspectedElement,
793 };
794 }
795
796 function inspectElementRaw(id: number): InspectedElement | null {
797 const internalInstance = idToInternalInstanceMap.get(id);

Callers

nothing calls this directly

Calls 5

cleanForBridgeFunction · 0.90
inspectElementRawFunction · 0.70
mergeInspectedPathsFunction · 0.70
updateSelectedElementFunction · 0.70
createIsPathAllowedFunction · 0.70

Tested by

no test coverage detected