/** * Copyright (c) Facebook, Inc. and its 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 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 type {InspectedElement} from './types'; import type {FrontendBridge} from 'react-devtools-shared/src/bridge'; import type {Element} from 'react-devtools-shared/src/devtools/views/Components/types'; type Props = {| bridge: FrontendBridge, element: Element, inspectedElement: InspectedElement, store: Store, |}; export default function InspectedElementStateTree({ bridge, element, inspectedElement, store, }: Props) { const {state} = inspectedElement; const entries = state != null ? Object.entries(state) : null; if (entries !== null) { entries.sort(alphaSortEntries); } const isEmpty = entries === null || entries.length === 0; const handleCopy = () => copy(serializeDataForCopy(((state: any): Object))); if (isEmpty) { return null; } else { return (
state
{!isEmpty && ( )}
{isEmpty &&
None
} {!isEmpty && (entries: any).map(([name, value]) => (
); } }