Skip to content

Commit c4595ca

Browse files
authored
Add ViewTransitionComponent to Stacks and DevTools (facebook#32034)
Just adding the name so it shows up. (Note that no experimental ones are added to the list of filters atm. Including SuspenseList etc.)
1 parent 74ea0c7 commit c4595ca

File tree

6 files changed

+46
-2
lines changed

6 files changed

+46
-2
lines changed

packages/react-devtools-shared/src/backend/fiber/DevToolsFiberComponentStack.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ export function describeFiber(
4343
SimpleMemoComponent,
4444
ForwardRef,
4545
ClassComponent,
46+
ViewTransitionComponent,
4647
} = workTagMap;
4748

4849
switch (workInProgress.tag) {
@@ -57,6 +58,8 @@ export function describeFiber(
5758
return describeBuiltInComponentFrame('Suspense');
5859
case SuspenseListComponent:
5960
return describeBuiltInComponentFrame('SuspenseList');
61+
case ViewTransitionComponent:
62+
return describeBuiltInComponentFrame('ViewTransition');
6063
case FunctionComponent:
6164
case IndeterminateComponent:
6265
case SimpleMemoComponent:
@@ -150,6 +153,7 @@ export function getOwnerStackByFiberInDev(
150153
HostComponent,
151154
SuspenseComponent,
152155
SuspenseListComponent,
156+
ViewTransitionComponent,
153157
} = workTagMap;
154158
try {
155159
let info = '';
@@ -177,6 +181,9 @@ export function getOwnerStackByFiberInDev(
177181
case SuspenseListComponent:
178182
info += describeBuiltInComponentFrame('SuspenseList');
179183
break;
184+
case ViewTransitionComponent:
185+
info += describeBuiltInComponentFrame('ViewTransition');
186+
break;
180187
}
181188

182189
let owner: void | null | Fiber | ReactComponentInfo = workInProgress;

packages/react-devtools-shared/src/backend/fiber/renderer.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import {
2727
ElementTypeSuspense,
2828
ElementTypeSuspenseList,
2929
ElementTypeTracingMarker,
30+
ElementTypeViewTransition,
3031
ElementTypeVirtual,
3132
StrictMode,
3233
} from 'react-devtools-shared/src/frontend/types';
@@ -383,6 +384,7 @@ export function getInternalReactConstants(version: string): {
383384
// want to fork again so we're adding it here instead
384385
YieldComponent: -1, // Removed
385386
Throw: 29,
387+
ViewTransitionComponent: 30, // Experimental
386388
};
387389
} else if (gte(version, '17.0.0-alpha')) {
388390
ReactTypeOfWork = {
@@ -418,6 +420,7 @@ export function getInternalReactConstants(version: string): {
418420
TracingMarkerComponent: -1, // Doesn't exist yet
419421
YieldComponent: -1, // Removed
420422
Throw: -1, // Doesn't exist yet
423+
ViewTransitionComponent: -1, // Doesn't exist yet
421424
};
422425
} else if (gte(version, '16.6.0-beta.0')) {
423426
ReactTypeOfWork = {
@@ -453,6 +456,7 @@ export function getInternalReactConstants(version: string): {
453456
TracingMarkerComponent: -1, // Doesn't exist yet
454457
YieldComponent: -1, // Removed
455458
Throw: -1, // Doesn't exist yet
459+
ViewTransitionComponent: -1, // Doesn't exist yet
456460
};
457461
} else if (gte(version, '16.4.3-alpha')) {
458462
ReactTypeOfWork = {
@@ -488,6 +492,7 @@ export function getInternalReactConstants(version: string): {
488492
TracingMarkerComponent: -1, // Doesn't exist yet
489493
YieldComponent: -1, // Removed
490494
Throw: -1, // Doesn't exist yet
495+
ViewTransitionComponent: -1, // Doesn't exist yet
491496
};
492497
} else {
493498
ReactTypeOfWork = {
@@ -523,6 +528,7 @@ export function getInternalReactConstants(version: string): {
523528
TracingMarkerComponent: -1, // Doesn't exist yet
524529
YieldComponent: 9,
525530
Throw: -1, // Doesn't exist yet
531+
ViewTransitionComponent: -1, // Doesn't exist yet
526532
};
527533
}
528534
// **********************************************************
@@ -565,6 +571,7 @@ export function getInternalReactConstants(version: string): {
565571
SuspenseListComponent,
566572
TracingMarkerComponent,
567573
Throw,
574+
ViewTransitionComponent,
568575
} = ReactTypeOfWork;
569576

570577
function resolveFiberType(type: any): $FlowFixMe {
@@ -673,6 +680,8 @@ export function getInternalReactConstants(version: string): {
673680
return 'Profiler';
674681
case TracingMarkerComponent:
675682
return 'TracingMarker';
683+
case ViewTransitionComponent:
684+
return 'ViewTransition';
676685
case Throw:
677686
// This should really never be visible.
678687
return 'Error';
@@ -907,6 +916,7 @@ export function attach(
907916
SuspenseListComponent,
908917
TracingMarkerComponent,
909918
Throw,
919+
ViewTransitionComponent,
910920
} = ReactTypeOfWork;
911921
const {
912922
ImmediatePriority,
@@ -1583,6 +1593,8 @@ export function attach(
15831593
return ElementTypeSuspenseList;
15841594
case TracingMarkerComponent:
15851595
return ElementTypeTracingMarker;
1596+
case ViewTransitionComponent:
1597+
return ElementTypeViewTransition;
15861598
default:
15871599
const typeSymbol = getTypeSymbol(type);
15881600

packages/react-devtools-shared/src/backend/types.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ export type WorkTagMap = {
7676
TracingMarkerComponent: WorkTag,
7777
YieldComponent: WorkTag,
7878
Throw: WorkTag,
79+
ViewTransitionComponent: WorkTag,
7980
};
8081

8182
export type HostInstance = Object;

packages/react-devtools-shared/src/frontend/types.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ export const ElementTypeSuspense = 12;
4949
export const ElementTypeSuspenseList = 13;
5050
export const ElementTypeTracingMarker = 14;
5151
export const ElementTypeVirtual = 15;
52+
export const ElementTypeViewTransition = 16;
5253

5354
// Different types of elements displayed in the Elements tree.
5455
// These types may be used to visually distinguish types,
@@ -66,7 +67,8 @@ export type ElementType =
6667
| 12
6768
| 13
6869
| 14
69-
| 15;
70+
| 15
71+
| 16;
7072

7173
// WARNING
7274
// The values below are referenced by ComponentFilters (which are saved via localStorage).

packages/react-reconciler/src/ReactFiberComponentStack.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@
77
* @flow
88
*/
99

10-
import {enableOwnerStacks} from 'shared/ReactFeatureFlags';
10+
import {
11+
enableOwnerStacks,
12+
enableViewTransition,
13+
} from 'shared/ReactFeatureFlags';
1114
import type {Fiber} from './ReactInternalTypes';
1215
import type {ReactComponentInfo} from 'shared/ReactTypes';
1316

@@ -23,6 +26,7 @@ import {
2326
SimpleMemoComponent,
2427
ClassComponent,
2528
HostText,
29+
ViewTransitionComponent,
2630
} from './ReactWorkTags';
2731
import {
2832
describeBuiltInComponentFrame,
@@ -52,6 +56,11 @@ function describeFiber(fiber: Fiber): string {
5256
return describeFunctionComponentFrame(fiber.type.render);
5357
case ClassComponent:
5458
return describeClassComponentFrame(fiber.type);
59+
case ViewTransitionComponent:
60+
if (enableViewTransition) {
61+
return describeBuiltInComponentFrame('ViewTransition');
62+
}
63+
// Fallthrough
5564
default:
5665
return '';
5766
}
@@ -123,6 +132,12 @@ export function getOwnerStackByFiberInDev(workInProgress: Fiber): string {
123132
case SuspenseListComponent:
124133
info += describeBuiltInComponentFrame('SuspenseList');
125134
break;
135+
case ViewTransitionComponent:
136+
if (enableViewTransition) {
137+
info += describeBuiltInComponentFrame('SuspenseList');
138+
break;
139+
}
140+
// Fallthrough
126141
case FunctionComponent:
127142
case SimpleMemoComponent:
128143
case ClassComponent:

packages/react-reconciler/src/getComponentNameFromFiber.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
disableLegacyMode,
1515
enableLegacyHidden,
1616
enableRenderableContext,
17+
enableViewTransition,
1718
} from 'shared/ReactFeatureFlags';
1819

1920
import {
@@ -45,6 +46,7 @@ import {
4546
CacheComponent,
4647
TracingMarkerComponent,
4748
Throw,
49+
ViewTransitionComponent,
4850
} from 'react-reconciler/src/ReactWorkTags';
4951
import getComponentNameFromType from 'shared/getComponentNameFromType';
5052
import {REACT_STRICT_MODE_TYPE} from 'shared/ReactSymbols';
@@ -139,7 +141,12 @@ export default function getComponentNameFromFiber(fiber: Fiber): string | null {
139141
return 'SuspenseList';
140142
case TracingMarkerComponent:
141143
return 'TracingMarker';
144+
case ViewTransitionComponent:
145+
if (enableViewTransition) {
146+
return 'ViewTransition';
147+
}
142148
// The display name for these tags come from the user-provided type:
149+
// Fallthrough
143150
case IncompleteClassComponent:
144151
case IncompleteFunctionComponent:
145152
if (disableLegacyMode) {

0 commit comments

Comments
 (0)