Home / Function/ InspectedElementStateTree() — react Function Reference

InspectedElementStateTree() — react Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  abbdd482_edd4_85ba_aff5_1b324cb4864f["InspectedElementStateTree()"]
  e495e7a2_ca5d_8be7_7ae7_0c5ccb871bc2["InspectedElementStateTree.js"]
  abbdd482_edd4_85ba_aff5_1b324cb4864f -->|defined in| e495e7a2_ca5d_8be7_7ae7_0c5ccb871bc2
  24a5b0f3_4e3a_ff70_e4ed_c4392045f885["serializeDataForCopy()"]
  abbdd482_edd4_85ba_aff5_1b324cb4864f -->|calls| 24a5b0f3_4e3a_ff70_e4ed_c4392045f885
  style abbdd482_edd4_85ba_aff5_1b324cb4864f fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/react-devtools-shared/src/devtools/views/Components/InspectedElementStateTree.js lines 32–90

export default function InspectedElementStateTree({
  bridge,
  element,
  inspectedElement,
  store,
}: Props): React.Node {
  const {state, type} = inspectedElement;
  if (state == null) {
    return null;
  }

  // HostSingleton and HostHoistable may have state that we don't want to expose to users
  const isHostComponent = type === ElementTypeHostComponent;
  const entries = Object.entries(state);
  const isEmpty = entries.length === 0;
  if (isEmpty || isHostComponent) {
    return null;
  }

  entries.sort(alphaSortEntries);
  const handleCopy = withPermissionsCheck(
    {permissions: ['clipboardWrite']},
    () => copy(serializeDataForCopy(state)),
  );

  return (
    <div>
      <div className={styles.HeaderRow}>
        <div className={styles.Header}>state</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={true}
            canEditValues={true}
            canRenamePaths={true}
            depth={1}
            element={element}
            hidden={false}
            inspectedElement={inspectedElement}
            name={name}
            path={[name]}
            pathRoot="state"
            store={store}
            value={value}
          />
        ))}
    </div>
  );
}

Domain

Subdomains

Frequently Asked Questions

What does InspectedElementStateTree() do?
InspectedElementStateTree() is a function in the react codebase, defined in packages/react-devtools-shared/src/devtools/views/Components/InspectedElementStateTree.js.
Where is InspectedElementStateTree() defined?
InspectedElementStateTree() is defined in packages/react-devtools-shared/src/devtools/views/Components/InspectedElementStateTree.js at line 32.
What does InspectedElementStateTree() call?
InspectedElementStateTree() 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