@@ -63,7 +63,16 @@ export default function WhatChanged({fiberID}: Props) {
63
63
return null ;
64
64
}
65
65
66
- if ( changeDescription . isFirstMount ) {
66
+ const {
67
+ context,
68
+ didHooksChange,
69
+ hooks,
70
+ isFirstMount,
71
+ props,
72
+ state,
73
+ } = changeDescription ;
74
+
75
+ if ( isFirstMount ) {
67
76
return (
68
77
< div className = { styles . Component } >
69
78
< label className = { styles . Label } > Why did this render?</ label >
@@ -76,21 +85,21 @@ export default function WhatChanged({fiberID}: Props) {
76
85
77
86
const changes = [ ] ;
78
87
79
- if ( changeDescription . context === true ) {
88
+ if ( context === true ) {
80
89
changes . push (
81
90
< div key = "context" className = { styles . Item } >
82
91
• Context changed
83
92
</ div > ,
84
93
) ;
85
94
} else if (
86
- typeof changeDescription . context === 'object' &&
87
- changeDescription . context !== null &&
88
- changeDescription . context . length !== 0
95
+ typeof context === 'object' &&
96
+ context !== null &&
97
+ context . length !== 0
89
98
) {
90
99
changes . push (
91
100
< div key = "context" className = { styles . Item } >
92
101
• Context changed:
93
- { changeDescription . context . map ( key => (
102
+ { context . map ( key => (
94
103
< span key = { key } className = { styles . Key } >
95
104
{ key }
96
105
</ span >
@@ -99,14 +108,11 @@ export default function WhatChanged({fiberID}: Props) {
99
108
) ;
100
109
}
101
110
102
- if ( changeDescription . didHooksChange ) {
103
- if (
104
- enableProfilerChangedHookIndices &&
105
- Array . isArray ( changeDescription . hooks )
106
- ) {
111
+ if ( didHooksChange ) {
112
+ if ( enableProfilerChangedHookIndices && Array . isArray ( hooks ) ) {
107
113
changes . push (
108
114
< div key = "hooks" className = { styles . Item } >
109
- • { hookIndicesToString ( changeDescription . hooks ) }
115
+ • { hookIndicesToString ( hooks ) }
110
116
</ div > ,
111
117
) ;
112
118
} else {
@@ -118,14 +124,11 @@ export default function WhatChanged({fiberID}: Props) {
118
124
}
119
125
}
120
126
121
- if (
122
- changeDescription . props !== null &&
123
- changeDescription . props . length !== 0
124
- ) {
127
+ if ( props !== null && props . length !== 0 ) {
125
128
changes . push (
126
129
< div key = "props" className = { styles . Item } >
127
130
• Props changed:
128
- { changeDescription . props . map ( key => (
131
+ { props . map ( key => (
129
132
< span key = { key } className = { styles . Key } >
130
133
{ key }
131
134
</ span >
@@ -134,14 +137,11 @@ export default function WhatChanged({fiberID}: Props) {
134
137
) ;
135
138
}
136
139
137
- if (
138
- changeDescription . state !== null &&
139
- changeDescription . state . length !== 0
140
- ) {
140
+ if ( state !== null && state . length !== 0 ) {
141
141
changes . push (
142
142
< div key = "state" className = { styles . Item } >
143
143
• State changed:
144
- { changeDescription . state . map ( key => (
144
+ { state . map ( key => (
145
145
< span key = { key } className = { styles . Key } >
146
146
{ key }
147
147
</ span >
0 commit comments