Commit 0b78161
authored
[Fiber] Highlight a Component with Deeply Equal Props in the Performance Track (#33660)
Stacked on #33658 and #33659.
If we detect that a component is receiving only deeply equal objects,
then we highlight it as potentially problematic and worth looking into.
<img width="1055" alt="Screenshot 2025-06-27 at 4 15 28 PM"
src="https://github.com/user-attachments/assets/e96c6a05-7fff-4fd7-b59a-36ed79f8e609"
/>
It's fairly conservative and can bail out for a number of reasons:
- We only log it on the first parent that triggered this case since
other children could be indirect causes.
- If children has changed then we bail out since this component will
rerender anyway. This means that it won't warn for a lot of cases that
receive plain DOM children since the DOM children won't themselves get
logged.
- If the component's total render time including children is 100ms or
less then we skip warning because rerendering might not be a big deal.
- We don't warn if you have shallow equality but could memoize the JSX
element itself since we don't typically recommend that and React
Compiler doesn't do that. It only warns if you have nested objects too.
- If the depth of the objects is deeper than like the 3 levels that we
print diffs for then we wouldn't warn since we don't know if they were
equal (although we might still warn on a child).
- If the component had any updates scheduled on itself (e.g. setState)
then we don't warn since it would rerender anyway. This should really
consider Context updates too but we don't do that atm. Technically you
should still memoize the incoming props even if you also had unrelated
updates since it could apply to deeper bailouts.1 parent dcf83f7 commit 0b78161
File tree
3 files changed
+84
-7
lines changed- packages
- react-reconciler/src
3 files changed
+84
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
143 | 143 | | |
144 | 144 | | |
145 | 145 | | |
| 146 | + | |
| 147 | + | |
146 | 148 | | |
147 | 149 | | |
148 | 150 | | |
| |||
3489 | 3491 | | |
3490 | 3492 | | |
3491 | 3493 | | |
| 3494 | + | |
3492 | 3495 | | |
3493 | 3496 | | |
3494 | 3497 | | |
| |||
3533 | 3536 | | |
3534 | 3537 | | |
3535 | 3538 | | |
| 3539 | + | |
3536 | 3540 | | |
3537 | 3541 | | |
3538 | 3542 | | |
| |||
3577 | 3581 | | |
3578 | 3582 | | |
3579 | 3583 | | |
| 3584 | + | |
3580 | 3585 | | |
3581 | 3586 | | |
3582 | 3587 | | |
| |||
4079 | 4084 | | |
4080 | 4085 | | |
4081 | 4086 | | |
| 4087 | + | |
4082 | 4088 | | |
4083 | 4089 | | |
4084 | 4090 | | |
| |||
4140 | 4146 | | |
4141 | 4147 | | |
4142 | 4148 | | |
| 4149 | + | |
| 4150 | + | |
4143 | 4151 | | |
4144 | 4152 | | |
4145 | 4153 | | |
| |||
4156 | 4164 | | |
4157 | 4165 | | |
4158 | 4166 | | |
| 4167 | + | |
4159 | 4168 | | |
4160 | 4169 | | |
4161 | 4170 | | |
| |||
4340 | 4349 | | |
4341 | 4350 | | |
4342 | 4351 | | |
| 4352 | + | |
4343 | 4353 | | |
4344 | 4354 | | |
4345 | 4355 | | |
| |||
4389 | 4399 | | |
4390 | 4400 | | |
4391 | 4401 | | |
| 4402 | + | |
| 4403 | + | |
4392 | 4404 | | |
4393 | 4405 | | |
4394 | 4406 | | |
| |||
4403 | 4415 | | |
4404 | 4416 | | |
4405 | 4417 | | |
| 4418 | + | |
4406 | 4419 | | |
4407 | 4420 | | |
4408 | 4421 | | |
| |||
4453 | 4466 | | |
4454 | 4467 | | |
4455 | 4468 | | |
| 4469 | + | |
| 4470 | + | |
4456 | 4471 | | |
4457 | 4472 | | |
4458 | 4473 | | |
| |||
Lines changed: 49 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
| |||
104 | 105 | | |
105 | 106 | | |
106 | 107 | | |
| 108 | + | |
107 | 109 | | |
108 | 110 | | |
109 | 111 | | |
| |||
153 | 155 | | |
154 | 156 | | |
155 | 157 | | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
156 | 175 | | |
157 | 176 | | |
158 | 177 | | |
| 178 | + | |
159 | 179 | | |
160 | 180 | | |
| 181 | + | |
161 | 182 | | |
162 | 183 | | |
163 | 184 | | |
| |||
168 | 189 | | |
169 | 190 | | |
170 | 191 | | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
171 | 197 | | |
172 | 198 | | |
173 | 199 | | |
174 | 200 | | |
175 | 201 | | |
| 202 | + | |
176 | 203 | | |
177 | 204 | | |
178 | 205 | | |
| |||
211 | 238 | | |
212 | 239 | | |
213 | 240 | | |
214 | | - | |
| 241 | + | |
215 | 242 | | |
216 | 243 | | |
217 | 244 | | |
218 | 245 | | |
219 | 246 | | |
220 | 247 | | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
221 | 269 | | |
222 | 270 | | |
223 | | - | |
224 | | - | |
225 | 271 | | |
226 | 272 | | |
227 | 273 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
161 | 161 | | |
162 | 162 | | |
163 | 163 | | |
164 | | - | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
165 | 171 | | |
166 | 172 | | |
167 | 173 | | |
| |||
177 | 183 | | |
178 | 184 | | |
179 | 185 | | |
| 186 | + | |
180 | 187 | | |
181 | 188 | | |
182 | 189 | | |
| |||
242 | 249 | | |
243 | 250 | | |
244 | 251 | | |
245 | | - | |
| 252 | + | |
246 | 253 | | |
247 | 254 | | |
248 | 255 | | |
| 256 | + | |
249 | 257 | | |
250 | 258 | | |
251 | 259 | | |
| 260 | + | |
252 | 261 | | |
253 | 262 | | |
254 | 263 | | |
| |||
262 | 271 | | |
263 | 272 | | |
264 | 273 | | |
| 274 | + | |
265 | 275 | | |
266 | 276 | | |
267 | 277 | | |
| |||
286 | 296 | | |
287 | 297 | | |
288 | 298 | | |
| 299 | + | |
289 | 300 | | |
290 | 301 | | |
291 | 302 | | |
| |||
304 | 315 | | |
305 | 316 | | |
306 | 317 | | |
307 | | - | |
| 318 | + | |
308 | 319 | | |
309 | 320 | | |
310 | 321 | | |
311 | 322 | | |
312 | 323 | | |
313 | | - | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
314 | 327 | | |
315 | 328 | | |
316 | 329 | | |
| |||
349 | 362 | | |
350 | 363 | | |
351 | 364 | | |
| 365 | + | |
352 | 366 | | |
353 | 367 | | |
354 | 368 | | |
| 369 | + | |
355 | 370 | | |
356 | 371 | | |
| 372 | + | |
357 | 373 | | |
0 commit comments