9
10
import {copy} from 'clipboard-js';
11
import * as React from 'react';
12
+import {ElementTypeHostComponent} from 'react-devtools-shared/src/types';
13
import Button from '../Button';
14
import ButtonIcon from '../ButtonIcon';
15
import KeyValue from './KeyValue';
34
inspectedElement,
35
store,
36
}: Props): React.Node {
36
- const {state} = inspectedElement;
37
+ const {state, type} = inspectedElement;
38
+
39
+ // HostSingleton and HostResource may have state that we don't want to expose to users
40
+ const isHostComponent = type === ElementTypeHostComponent;
41
42
const entries = state != null ? Object.entries(state) : null;
43
+ const isEmpty = entries === null || entries.length === 0;
44
+
45
+ if (isEmpty || isHostComponent) {
46
+ return null;
47
+ }
48
+
49
if (entries !== null) {
50
entries.sort(alphaSortEntries);
51
}
52
43
- const isEmpty = entries === null || entries.length === 0;
44
-
53
const handleCopy = () => copy(serializeDataForCopy(((state: any): Object)));
54
47
- if (isEmpty) {
48
- return null;
49
- } else {
50
- return (
51
- <div className={styles.InspectedElementTree}>
52
- <div className={styles.HeaderRow}>
53
- <div className={styles.Header}>state</div>
54
- {!isEmpty && (
55
- <Button onClick={handleCopy} title="Copy to clipboard">
56
- <ButtonIcon type="copy" />
57
- </Button>
58
- )}
59
- </div>
60
- {isEmpty && <div className={styles.Empty}>None</div>}
61
- {!isEmpty &&
62
- (entries: any).map(([name, value]) => (
63
- <KeyValue
64
- key={name}
65
- alphaSort={true}
66
- bridge={bridge}
67
- canDeletePaths={true}
68
- canEditValues={true}
69
- canRenamePaths={true}
70
- depth={1}
71
- element={element}
72
- hidden={false}
73
- inspectedElement={inspectedElement}
74
- name={name}
75
- path={[name]}
76
- pathRoot="state"
77
- store={store}
78
- value={value}
79
- />
80
- ))}
55
+ return (
56
+ <div className={styles.InspectedElementTree}>
57
+ <div className={styles.HeaderRow}>
58
+ <div className={styles.Header}>state</div>
59
+ {!isEmpty && (
60
+ <Button onClick={handleCopy} title="Copy to clipboard">
61
+ <ButtonIcon type="copy" />
62
+ </Button>
63
+ )}
64
</div>
82
- );
83
- }
65
+ {isEmpty && <div className={styles.Empty}>None</div>}
66
+ {!isEmpty &&
67
+ (entries: any).map(([name, value]) => (
68
+ <KeyValue
69
+ key={name}
70
+ alphaSort={true}
71
+ bridge={bridge}
72
+ canDeletePaths={true}
73
+ canEditValues={true}
74
+ canRenamePaths={true}
75
+ depth={1}
76
+ element={element}
77
+ hidden={false}
78
+ inspectedElement={inspectedElement}
79
+ name={name}
80
+ path={[name]}
81
+ pathRoot="state"
82
+ store={store}
83
+ value={value}
84
+ />
85
+ ))}
86
+ </div>
87
+ );
88
}