Home / Function/ InspectedElementContextTree() — react Function Reference

InspectedElementContextTree() — react Function Reference

Architecture documentation for the InspectedElementContextTree() function in InspectedElementContextTree.js from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  5ce17f62_0635_c272_7b59_0d926f50ddae["InspectedElementContextTree()"]
  738bd757_ad86_9e31_fd90_992339125271["InspectedElementContextTree.js"]
  5ce17f62_0635_c272_7b59_0d926f50ddae -->|defined in| 738bd757_ad86_9e31_fd90_992339125271
  84752d7a_6d41_4e6c_366a_8457d769aa0f["serializeDataForCopy()"]
  5ce17f62_0635_c272_7b59_0d926f50ddae -->|calls| 84752d7a_6d41_4e6c_366a_8457d769aa0f
  style 5ce17f62_0635_c272_7b59_0d926f50ddae fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/react-devtools-shared/src/devtools/views/Components/InspectedElementContextTree.js lines 35–105

export default function InspectedElementContextTree({
  bridge,
  element,
  inspectedElement,
  store,
}: Props): React.Node {
  const {hasLegacyContext, context, type} = inspectedElement;

  const isReadOnly = type !== ElementTypeClass && type !== ElementTypeFunction;

  if (context == null) {
    return null;
  }

  const entries = Object.entries(context);
  entries.sort(alphaSortEntries);
  const isEmpty = entries.length === 0;

  const handleCopy = withPermissionsCheck(
    {permissions: ['clipboardWrite']},
    () => copy(serializeDataForCopy(context)),
  );

  // We add an object with a "value" key as a wrapper around Context data
  // so that we can use the shared <KeyValue> component to display it.
  // This wrapper object can't be renamed.
  // $FlowFixMe[missing-local-annot]
  const canRenamePathsAtDepth = depth => depth > 1;

  if (isEmpty) {
    return null;
  } else {
    return (
      <div>
        <div className={styles.HeaderRow}>
          <div className={styles.Header}>
            {hasLegacyContext ? 'legacy context' : 'context'}
          </div>
          {!isEmpty && (
            <Button onClick={handleCopy} title="Copy to clipboard">
              <ButtonIcon type="copy" />
            </Button>
          )}
        </div>
        {isEmpty && <div className={styles.Empty}>None</div>}
        {!isEmpty &&
          (entries: any).map(([name, value]) => (
            <KeyValue
              key={name}
              alphaSort={true}
              bridge={bridge}
              canDeletePaths={!isReadOnly}
              canEditValues={!isReadOnly}
              canRenamePaths={!isReadOnly}
              canRenamePathsAtDepth={canRenamePathsAtDepth}
              depth={1}
              element={element}
              hidden={false}
              inspectedElement={inspectedElement}
              name={name}
              path={[name]}
              pathRoot="context"
              store={store}
              type="context"
              value={value}
            />
          ))}
      </div>
    );
  }
}

Domain

Subdomains

Frequently Asked Questions

What does InspectedElementContextTree() do?
InspectedElementContextTree() is a function in the react codebase, defined in packages/react-devtools-shared/src/devtools/views/Components/InspectedElementContextTree.js.
Where is InspectedElementContextTree() defined?
InspectedElementContextTree() is defined in packages/react-devtools-shared/src/devtools/views/Components/InspectedElementContextTree.js at line 35.
What does InspectedElementContextTree() call?
InspectedElementContextTree() calls 1 function(s): serializeDataForCopy.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free