Home / File/ InspectedElementStateTree.js — react Source File

InspectedElementStateTree.js — react Source File

Architecture documentation for InspectedElementStateTree.js, a javascript file in the react codebase. 16 imports, 1 dependents.

File javascript BabelCompiler Validation 16 imports 1 dependents 1 functions

Entity Profile

Dependency Diagram

graph LR
  e495e7a2_ca5d_8be7_7ae7_0c5ccb871bc2["InspectedElementStateTree.js"]
  f9049b08_60f8_abce_a6a6_153f88447124["Button.js"]
  e495e7a2_ca5d_8be7_7ae7_0c5ccb871bc2 --> f9049b08_60f8_abce_a6a6_153f88447124
  f71ee326_17f0_7db4_4178_2763fb1c2ad1["Button"]
  e495e7a2_ca5d_8be7_7ae7_0c5ccb871bc2 --> f71ee326_17f0_7db4_4178_2763fb1c2ad1
  9f39024f_b905_9b0f_2fc7_e24785732638["ButtonIcon.js"]
  e495e7a2_ca5d_8be7_7ae7_0c5ccb871bc2 --> 9f39024f_b905_9b0f_2fc7_e24785732638
  4690d9c0_cb81_9593_7817_f9e61a49f9e7["ButtonIcon"]
  e495e7a2_ca5d_8be7_7ae7_0c5ccb871bc2 --> 4690d9c0_cb81_9593_7817_f9e61a49f9e7
  276bc34e_3008_101e_3cd7_cc895fcd3848["KeyValue.js"]
  e495e7a2_ca5d_8be7_7ae7_0c5ccb871bc2 --> 276bc34e_3008_101e_3cd7_cc895fcd3848
  b5067ef5_22cb_1a20_66d3_9a573b206f48["KeyValue"]
  e495e7a2_ca5d_8be7_7ae7_0c5ccb871bc2 --> b5067ef5_22cb_1a20_66d3_9a573b206f48
  d7b27d30_728f_ba37_ed97_d371fbd3de62["utils.js"]
  e495e7a2_ca5d_8be7_7ae7_0c5ccb871bc2 --> d7b27d30_728f_ba37_ed97_d371fbd3de62
  703db4ef_ef9f_8a4b_eecf_6dad80aa9ddd["alphaSortEntries"]
  e495e7a2_ca5d_8be7_7ae7_0c5ccb871bc2 --> 703db4ef_ef9f_8a4b_eecf_6dad80aa9ddd
  24a5b0f3_4e3a_ff70_e4ed_c4392045f885["serializeDataForCopy"]
  e495e7a2_ca5d_8be7_7ae7_0c5ccb871bc2 --> 24a5b0f3_4e3a_ff70_e4ed_c4392045f885
  bba85af0_a356_d0c5_4d12_914508b89593["store.js"]
  e495e7a2_ca5d_8be7_7ae7_0c5ccb871bc2 --> bba85af0_a356_d0c5_4d12_914508b89593
  2337051b_9399_908a_f16c_81724ab026b7["InspectedElementSharedStyles.css"]
  e495e7a2_ca5d_8be7_7ae7_0c5ccb871bc2 --> 2337051b_9399_908a_f16c_81724ab026b7
  1e290487_2c6f_fbaf_7be9_e14d5df52457["clipboard-js"]
  e495e7a2_ca5d_8be7_7ae7_0c5ccb871bc2 --> 1e290487_2c6f_fbaf_7be9_e14d5df52457
  ac587885_e294_a1e9_b13f_5e7b920fdb42["react"]
  e495e7a2_ca5d_8be7_7ae7_0c5ccb871bc2 --> ac587885_e294_a1e9_b13f_5e7b920fdb42
  aec7978f_0a19_ba93_de9e_ac8cf5ddc74b["types"]
  e495e7a2_ca5d_8be7_7ae7_0c5ccb871bc2 --> aec7978f_0a19_ba93_de9e_ac8cf5ddc74b
  style e495e7a2_ca5d_8be7_7ae7_0c5ccb871bc2 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

/**
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 *
 * @flow
 */

import {copy} from 'clipboard-js';
import * as React from 'react';
import {ElementTypeHostComponent} from 'react-devtools-shared/src/frontend/types';
import Button from '../Button';
import ButtonIcon from '../ButtonIcon';
import KeyValue from './KeyValue';
import {alphaSortEntries, serializeDataForCopy} from '../utils';
import Store from '../../store';
import styles from './InspectedElementSharedStyles.css';
import {withPermissionsCheck} from 'react-devtools-shared/src/frontend/utils/withPermissionsCheck';

import type {InspectedElement} from 'react-devtools-shared/src/frontend/types';
import type {FrontendBridge} from 'react-devtools-shared/src/bridge';
import type {Element} from 'react-devtools-shared/src/frontend/types';

type Props = {
  bridge: FrontendBridge,
  element: Element,
  inspectedElement: InspectedElement,
  store: Store,
};

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.js do?
InspectedElementStateTree.js is a source file in the react codebase, written in javascript. It belongs to the BabelCompiler domain, Validation subdomain.
What functions are defined in InspectedElementStateTree.js?
InspectedElementStateTree.js defines 1 function(s): InspectedElementStateTree.
What does InspectedElementStateTree.js depend on?
InspectedElementStateTree.js imports 16 module(s): Button, Button.js, ButtonIcon, ButtonIcon.js, InspectedElementSharedStyles.css, KeyValue, KeyValue.js, alphaSortEntries, and 8 more.
What files import InspectedElementStateTree.js?
InspectedElementStateTree.js is imported by 1 file(s): InspectedElementView.js.
Where is InspectedElementStateTree.js in the architecture?
InspectedElementStateTree.js is located at packages/react-devtools-shared/src/devtools/views/Components/InspectedElementStateTree.js (domain: BabelCompiler, subdomain: Validation, directory: packages/react-devtools-shared/src/devtools/views/Components).

Analyze Your Own Codebase

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

Try Supermodel Free