@@ -20,71 +20,6 @@ import getLinkComponent from './getLinkComponent';
20
20
import { toggleExpanded , setCurrentTabInApp } from '../../../actions/actions' ;
21
21
import { useStoreContext } from '../../../store' ;
22
22
23
- // const exclude = [
24
- // 'childExpirationTime',
25
- // 'staticContext',
26
- // '_debugSource',
27
- // 'actualDuration',
28
- // 'actualStartTime',
29
- // 'treeBaseDuration',
30
- // '_debugID',
31
- // '_debugIsCurrentlyTiming',
32
- // 'selfBaseDuration',
33
- // 'expirationTime',
34
- // 'effectTag',
35
- // 'alternate',
36
- // '_owner',
37
- // '_store',
38
- // 'get key',
39
- // 'ref',
40
- // '_self',
41
- // '_source',
42
- // 'firstBaseUpdate',
43
- // 'updateQueue',
44
- // 'lastBaseUpdate',
45
- // 'shared',
46
- // 'responders',
47
- // 'pending',
48
- // 'lanes',
49
- // 'childLanes',
50
- // 'effects',
51
- // 'memoizedState',
52
- // 'pendingProps',
53
- // 'lastEffect',
54
- // 'firstEffect',
55
- // 'tag',
56
- // 'baseState',
57
- // 'baseQueue',
58
- // 'dependencies',
59
- // 'Consumer',
60
- // 'context',
61
- // '_currentRenderer',
62
- // '_currentRenderer2',
63
- // 'mode',
64
- // 'flags',
65
- // 'nextEffect',
66
- // 'sibling',
67
- // 'create',
68
- // 'deps',
69
- // 'next',
70
- // 'destroy',
71
- // 'parentSub',
72
- // 'child',
73
- // 'key',
74
- // 'return',
75
- // 'children',
76
- // '$$typeof',
77
- // '_threadCount',
78
- // '_calculateChangedBits',
79
- // '_currentValue',
80
- // '_currentValue2',
81
- // 'Provider',
82
- // '_context',
83
- // 'stateNode',
84
- // 'elementType',
85
- // 'type',
86
- // ];
87
-
88
23
const defaultMargin = {
89
24
top : 30 ,
90
25
left : 30 ,
@@ -187,38 +122,15 @@ export default function ComponentMap({
187
122
return `${ renderTime } ms ` ;
188
123
} ;
189
124
190
- const formatProps = ( data ) => {
191
- console . log ( 'ComponentMap' , { data } ) ;
192
- const propsFormat = [ ] ;
193
- // const nestedObj = [];
194
- for ( const key in data ) {
195
- if (
196
- // data[key] !== 'reactFiber' &&
197
- typeof data [ key ] !== 'object'
198
- // exclude.includes(key) !== true
199
- ) {
200
- propsFormat . push ( < p className = 'stateprops' > { `${ key } : ${ data [ key ] } ` } </ p > ) ;
201
- }
202
- // else if (
203
- // data[key] !== 'reactFiber' &&
204
- // typeof data[key] === 'object'
205
- // exclude.includes(key) !== true
206
- // ) {
207
- // const result = formatProps(data[key]);
208
- // nestedObj.push(result);
209
- // }
210
- }
211
- // if (nestedObj) {
212
- // propsFormat.push(nestedObj);
213
- // }
214
- if ( propsFormat . length ) return propsFormat ;
215
- } ;
216
-
217
- const formatContext = ( data ) => {
125
+ const formatData = ( data , type ) => {
218
126
const contextFormat = [ ] ;
219
127
for ( const key in data ) {
220
128
// Suggestion: update the front end to display as a list if we have object
221
- contextFormat . push ( < p className = 'statecontext' > { `${ key } : ${ data [ key ] } ` } </ p > ) ;
129
+ let inputData = data [ key ] ;
130
+ if ( inputData !== null && typeof inputData === 'object' ) {
131
+ inputData = JSON . stringify ( inputData ) ;
132
+ }
133
+ contextFormat . push ( < p className = { `${ type } -item` } > { `${ key } : ${ inputData } ` } </ p > ) ;
222
134
}
223
135
return contextFormat ;
224
136
} ;
@@ -437,14 +349,18 @@ export default function ComponentMap({
437
349
< div style = { React . scrollStyle } >
438
350
< div className = 'tooltipWrapper' >
439
351
< h2 > Props:</ h2 >
440
- { formatProps ( tooltipData . componentData . props ) }
352
+ { formatData ( tooltipData . componentData . props , 'props' ) }
353
+ </ div >
354
+
355
+ < div className = 'tooltipWrapper' >
356
+ < h2 > Initial Context:</ h2 >
357
+ { formatData ( tooltipData . componentData . context , 'context' ) }
358
+ </ div >
359
+
360
+ < div className = 'tooltipWrapper' >
361
+ < h2 > State:</ h2 >
362
+ { formatData ( tooltipData . componentData . state , 'state' ) }
441
363
</ div >
442
- { tooltipData . componentData . context && (
443
- < div className = 'tooltipWrapper' >
444
- < h2 > Context:</ h2 >
445
- { formatContext ( tooltipData . componentData . context ) }
446
- </ div >
447
- ) }
448
364
</ div >
449
365
</ div >
450
366
</ TooltipInPortal >
0 commit comments