MCPcopy Index your code
hub / github.com/react/react / printElement

Function printElement

packages/react-devtools-shared/src/devtools/utils.js:20–55  ·  view source on GitHub ↗
(
  element: Element,
  includeWeight: boolean = false,
)

Source from the content-addressed store, hash-verified

18import type Store from './store';
19
20export function printElement(
21 element: Element,
22 includeWeight: boolean = false,
23): string {
24 let prefix = ' ';
25 if (element.children.length > 0) {
26 prefix = element.isCollapsed ? '▸' : '▾';
27 }
28
29 let key = '';
30 if (element.key !== null) {
31 key = ` key="${element.key}"`;
32 }
33
34 let name = '';
35 if (element.nameProp !== null) {
36 name = ` name="${element.nameProp}"`;
37 }
38
39 let hocDisplayNames = null;
40 if (element.hocDisplayNames !== null) {
41 hocDisplayNames = [...element.hocDisplayNames];
42 }
43
44 const hocs =
45 hocDisplayNames === null ? '' : ` [${hocDisplayNames.join('][')}]`;
46
47 let suffix = '';
48 if (includeWeight) {
49 suffix = ` (${element.isCollapsed ? 1 : element.weight})`;
50 }
51
52 return `${' '.repeat(element.depth + 1)}${prefix} <${
53 element.displayName || 'null'
54 }${key}${name}>${hocs}${suffix}`;
55}
56
57function printRects(rects: SuspenseNode['rects']): string {
58 if (rects === null) {

Callers 2

printOwnersListFunction · 0.85
printStoreFunction · 0.85

Calls 1

joinMethod · 0.80

Tested by

no test coverage detected