Read index off the Fiber
Dan Abramov committed
Apr 24, 2019 at 15:05 UTC
f123763fe1b3d8c9bf188249afcc32baff3cc3fa
2 files changed
+3
-18
src/backend/renderer.js
+3
-17
@@ -324,7 +324,7 @@ export function attach(
324
// TODO: we might want to change the data structure once we no longer suppport Stack versions of `getData`.
325
// TODO: Keep in sync with getElementType()
326
function getDataForFiber(fiber: Fiber): FiberData {
327
- const { elementType, type, key, index, tag } = fiber;
327
+ const { elementType, type, key, tag } = fiber;
328
329
// This is to support lazy components with a Promise as the type.
330
// see https://github.com/facebook/react/pull/13397
@@ -345,7 +345,6 @@ export function attach(
345
fiberData = {
346
displayName: getDisplayName(resolvedType),
347
key,
348
- index,
348
type: ElementTypeClass,
349
};
350
break;
@@ -354,7 +353,6 @@ export function attach(
353
fiberData = {
354
displayName: getDisplayName(resolvedType),
355
key,
357
- index,
356
type: ElementTypeFunction,
357
};
358
break;
@@ -362,7 +360,6 @@ export function attach(
360
fiberData = {
361
displayName: null,
362
key,
365
- index,
363
type: ElementTypeEventComponent,
364
};
365
break;
@@ -379,7 +376,6 @@ export function attach(
376
fiberData = {
377
displayName,
378
key,
382
- index,
379
type: ElementTypeEventTarget,
380
};
381
break;
@@ -392,7 +388,6 @@ export function attach(
388
fiberData = {
389
displayName,
390
key,
395
- index,
391
type: ElementTypeForwardRef,
392
};
393
break;
@@ -400,7 +395,6 @@ export function attach(
395
return {
396
displayName: null,
397
key: null,
403
- index: 0,
398
type: ElementTypeRoot,
399
};
400
case HostPortal:
@@ -410,7 +404,6 @@ export function attach(
404
return {
405
displayName: null,
406
key,
413
- index,
407
type: ElementTypeOtherOrUnknown,
408
};
409
case MemoComponent:
@@ -424,7 +417,6 @@ export function attach(
417
fiberData = {
418
displayName,
419
key,
427
- index,
420
type: ElementTypeMemo,
421
};
422
break;
@@ -438,7 +430,6 @@ export function attach(
430
return {
431
displayName: null,
432
key: null,
441
- index,
433
type: ElementTypeOtherOrUnknown,
434
};
435
case CONTEXT_PROVIDER_NUMBER:
@@ -453,7 +444,6 @@ export function attach(
444
fiberData = {
445
displayName,
446
key,
456
- index,
447
type: ElementTypeContext,
448
};
449
break;
@@ -472,7 +462,6 @@ export function attach(
462
fiberData = {
463
displayName,
464
key,
475
- index,
465
type: ElementTypeContext,
466
};
467
break;
@@ -481,7 +470,6 @@ export function attach(
470
fiberData = {
471
displayName: null,
472
key,
484
- index,
473
type: ElementTypeOtherOrUnknown,
474
};
475
break;
@@ -491,7 +479,6 @@ export function attach(
479
fiberData = {
480
displayName: 'Suspense',
481
key,
494
- index,
482
type: ElementTypeSuspense,
483
};
484
break;
@@ -500,7 +487,6 @@ export function attach(
487
fiberData = {
488
displayName: `Profiler(${fiber.memoizedProps.id})`,
489
key,
503
- index,
490
type: ElementTypeProfiler,
491
};
492
break;
@@ -510,7 +496,6 @@ export function attach(
496
fiberData = {
497
displayName: null,
498
key,
513
- index,
499
type: ElementTypeOtherOrUnknown,
500
};
501
break;
@@ -2115,7 +2100,8 @@ export function attach(
2100
}
2101
2102
function getPathFrame(fiber: Fiber): PathFrame {
2118
- let { displayName, key, index } = getDataForFiber(fiber);
2103
+ const { displayName, key } = getDataForFiber(fiber);
2104
+ let index = fiber.index;
2105
if (fiber.tag === HostRoot) {
2106
// Roots don't have a real index.
2107
// Instead, we'll use the order in which it mounted.
src/backend/types.js
-1
@@ -15,7 +15,6 @@ export type Fiber = Object;
15
// to keep the number of attributes small.
16
export type FiberData = {|
17
key: string | null,
18
- index: number,
18
displayName: string | null,
19
type: ElementType,
20
|};