GeezerVison is showing github.com — add <TracingMarker> component boilerplate (#23275) · react/react@a6987be
File treeExpand file treeCollapse file tree Open diff view settings react-devtools-shared/src
Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: packages/react-devtools-shared/src/backend/renderer.js +13Lines changed: 13 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -24,6 +24,7 @@ import { | 24 | 24 | ElementTypeRoot, | 25 | 25 | ElementTypeSuspense, | 26 | 26 | ElementTypeSuspenseList, | | 27 | + ElementTypeTracingMarker, | 27 | 28 | StrictMode, | 28 | 29 | } from 'react-devtools-shared/src/types'; | 29 | 30 | import { | @@ -247,6 +248,8 @@ export function getInternalReactConstants( | 247 | 248 | SimpleMemoComponent: 15, | 248 | 249 | SuspenseComponent: 13, | 249 | 250 | SuspenseListComponent: 19, // Experimental | | 251 | + TracingMarkerComponent: 25, // Experimental - This is technically in 18 but we don't | | 252 | + // want to fork again so we're adding it here instead | 250 | 253 | YieldComponent: -1, // Removed | 251 | 254 | }; | 252 | 255 | } else if (gte(version, '17.0.0-alpha')) { | @@ -277,6 +280,7 @@ export function getInternalReactConstants( | 277 | 280 | SimpleMemoComponent: 15, | 278 | 281 | SuspenseComponent: 13, | 279 | 282 | SuspenseListComponent: 19, // Experimental | | 283 | + TracingMarkerComponent: -1, // Doesn't exist yet | 280 | 284 | YieldComponent: -1, // Removed | 281 | 285 | }; | 282 | 286 | } else if (gte(version, '16.6.0-beta.0')) { | @@ -307,6 +311,7 @@ export function getInternalReactConstants( | 307 | 311 | SimpleMemoComponent: 15, | 308 | 312 | SuspenseComponent: 13, | 309 | 313 | SuspenseListComponent: 19, // Experimental | | 314 | + TracingMarkerComponent: -1, // Doesn't exist yet | 310 | 315 | YieldComponent: -1, // Removed | 311 | 316 | }; | 312 | 317 | } else if (gte(version, '16.4.3-alpha')) { | @@ -337,6 +342,7 @@ export function getInternalReactConstants( | 337 | 342 | SimpleMemoComponent: -1, // Doesn't exist yet | 338 | 343 | SuspenseComponent: 16, | 339 | 344 | SuspenseListComponent: -1, // Doesn't exist yet | | 345 | + TracingMarkerComponent: -1, // Doesn't exist yet | 340 | 346 | YieldComponent: -1, // Removed | 341 | 347 | }; | 342 | 348 | } else { | @@ -367,6 +373,7 @@ export function getInternalReactConstants( | 367 | 373 | SimpleMemoComponent: -1, // Doesn't exist yet | 368 | 374 | SuspenseComponent: 16, | 369 | 375 | SuspenseListComponent: -1, // Doesn't exist yet | | 376 | + TracingMarkerComponent: -1, // Doesn't exist yet | 370 | 377 | YieldComponent: 9, | 371 | 378 | }; | 372 | 379 | } | @@ -405,6 +412,7 @@ export function getInternalReactConstants( | 405 | 412 | SimpleMemoComponent, | 406 | 413 | SuspenseComponent, | 407 | 414 | SuspenseListComponent, | | 415 | + TracingMarkerComponent, | 408 | 416 | } = ReactTypeOfWork; | 409 | 417 |
| 410 | 418 | function resolveFiberType(type: any) { | @@ -484,6 +492,8 @@ export function getInternalReactConstants( | 484 | 492 | return 'SuspenseList'; | 485 | 493 | case Profiler: | 486 | 494 | return 'Profiler'; | | 495 | + case TracingMarkerComponent: | | 496 | + return 'TracingMarker'; | 487 | 497 | default: | 488 | 498 | const typeSymbol = getTypeSymbol(type); | 489 | 499 |
| @@ -583,6 +593,7 @@ export function attach( | 583 | 593 | SimpleMemoComponent, | 584 | 594 | SuspenseComponent, | 585 | 595 | SuspenseListComponent, | | 596 | + TracingMarkerComponent, | 586 | 597 | } = ReactTypeOfWork; | 587 | 598 | const { | 588 | 599 | ImmediatePriority, | @@ -1044,6 +1055,8 @@ export function attach( | 1044 | 1055 | return ElementTypeSuspense; | 1045 | 1056 | case SuspenseListComponent: | 1046 | 1057 | return ElementTypeSuspenseList; | | 1058 | + case TracingMarkerComponent: | | 1059 | + return ElementTypeTracingMarker; | 1047 | 1060 | default: | 1048 | 1061 | const typeSymbol = getTypeSymbol(type); | 1049 | 1062 |
| |
Collapse file Copy file name to clipboardExpand all lines: packages/react-devtools-shared/src/backend/types.js +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -53,6 +53,7 @@ export type WorkTagMap = {| | 53 | 53 | SimpleMemoComponent: WorkTag, | 54 | 54 | SuspenseComponent: WorkTag, | 55 | 55 | SuspenseListComponent: WorkTag, | | 56 | + TracingMarkerComponent: WorkTag, | 56 | 57 | YieldComponent: WorkTag, | 57 | 58 | |}; | 58 | 59 |
| |
Collapse file Copy file name to clipboardExpand all lines: packages/react-devtools-shared/src/types.js +2-1Lines changed: 2 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -32,11 +32,12 @@ export const ElementTypeProfiler = 10; | 32 | 32 | export const ElementTypeRoot = 11; | 33 | 33 | export const ElementTypeSuspense = 12; | 34 | 34 | export const ElementTypeSuspenseList = 13; | | 35 | +export const ElementTypeTracingMarker = 14; | 35 | 36 |
| 36 | 37 | // Different types of elements displayed in the Elements tree. | 37 | 38 | // These types may be used to visually distinguish types, | 38 | 39 | // or to enable/disable certain functionality. | 39 | | -export type ElementType = 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13; | | 40 | +export type ElementType = 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14; | 40 | 41 |
| 41 | 42 | // WARNING | 42 | 43 | // The values below are referenced by ComponentFilters (which are saved via localStorage). | |
Collapse file Copy file name to clipboardExpand all lines: packages/react-devtools-shared/src/utils.js +6-1Lines changed: 6 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -22,7 +22,10 @@ import { | 22 | 22 | StrictMode, | 23 | 23 | Suspense, | 24 | 24 | } from 'react-is'; | 25 | | -import {REACT_SUSPENSE_LIST_TYPE as SuspenseList} from 'shared/ReactSymbols'; | | 25 | +import { | | 26 | + REACT_SUSPENSE_LIST_TYPE as SuspenseList, | | 27 | + REACT_TRACING_MARKER_TYPE as TracingMarker, | | 28 | +} from 'shared/ReactSymbols'; | 26 | 29 | import { | 27 | 30 | TREE_OPERATION_ADD, | 28 | 31 | TREE_OPERATION_REMOVE, | @@ -684,6 +687,8 @@ export function getDisplayNameForReactElement( | 684 | 687 | return 'Suspense'; | 685 | 688 | case SuspenseList: | 686 | 689 | return 'SuspenseList'; | | 690 | + case TracingMarker: | | 691 | + return 'TracingMarker'; | 687 | 692 | default: | 688 | 693 | const {type} = element; | 689 | 694 | if (typeof type === 'string') { | |
Collapse file Copy file name to clipboardExpand all lines: packages/react-reconciler/src/ReactFiber.new.js +20Lines changed: 20 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -25,6 +25,7 @@ import { | 25 | 25 | enableScopeAPI, | 26 | 26 | enableSyncDefaultUpdates, | 27 | 27 | allowConcurrentByDefault, | | 28 | + enableTransitionTracing, | 28 | 29 | } from 'shared/ReactFeatureFlags'; | 29 | 30 | import { | 30 | 31 | supportsPersistence, | @@ -56,6 +57,7 @@ import { | 56 | 57 | OffscreenComponent, | 57 | 58 | LegacyHiddenComponent, | 58 | 59 | CacheComponent, | | 60 | + TracingMarkerComponent, | 59 | 61 | } from './ReactWorkTags'; | 60 | 62 | import getComponentNameFromFiber from 'react-reconciler/src/getComponentNameFromFiber'; | 61 | 63 |
| @@ -91,6 +93,7 @@ import { | 91 | 93 | REACT_OFFSCREEN_TYPE, | 92 | 94 | REACT_LEGACY_HIDDEN_TYPE, | 93 | 95 | REACT_CACHE_TYPE, | | 96 | + REACT_TRACING_MARKER_TYPE, | 94 | 97 | } from 'shared/ReactSymbols'; | 95 | 98 |
| 96 | 99 | export type {Fiber}; | @@ -521,6 +524,11 @@ export function createFiberFromTypeAndProps( | 521 | 524 | return createFiberFromCache(pendingProps, mode, lanes, key); | 522 | 525 | } | 523 | 526 | // eslint-disable-next-line no-fallthrough | | 527 | + case REACT_TRACING_MARKER_TYPE: | | 528 | + if (enableTransitionTracing) { | | 529 | + return createFiberFromTracingMarker(pendingProps, mode, lanes, key); | | 530 | + } | | 531 | + // eslint-disable-next-line no-fallthrough | 524 | 532 | default: { | 525 | 533 | if (typeof type === 'object' && type !== null) { | 526 | 534 | switch (type.$$typeof) { | @@ -746,6 +754,18 @@ export function createFiberFromCache( | 746 | 754 | return fiber; | 747 | 755 | } | 748 | 756 |
| | 757 | +export function createFiberFromTracingMarker( | | 758 | + pendingProps: any, | | 759 | + mode: TypeOfMode, | | 760 | + lanes: Lanes, | | 761 | + key: null | string, | | 762 | +) { | | 763 | + const fiber = createFiber(TracingMarkerComponent, pendingProps, key, mode); | | 764 | + fiber.elementType = REACT_TRACING_MARKER_TYPE; | | 765 | + fiber.lanes = lanes; | | 766 | + return fiber; | | 767 | +} | | 768 | + | 749 | 769 | export function createFiberFromText( | 750 | 770 | content: string, | 751 | 771 | mode: TypeOfMode, | |
Collapse file Copy file name to clipboardExpand all lines: packages/react-reconciler/src/ReactFiber.old.js +20Lines changed: 20 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -25,6 +25,7 @@ import { | 25 | 25 | enableScopeAPI, | 26 | 26 | enableSyncDefaultUpdates, | 27 | 27 | allowConcurrentByDefault, | | 28 | + enableTransitionTracing, | 28 | 29 | } from 'shared/ReactFeatureFlags'; | 29 | 30 | import { | 30 | 31 | supportsPersistence, | @@ -56,6 +57,7 @@ import { | 56 | 57 | OffscreenComponent, | 57 | 58 | LegacyHiddenComponent, | 58 | 59 | CacheComponent, | | 60 | + TracingMarkerComponent, | 59 | 61 | } from './ReactWorkTags'; | 60 | 62 | import getComponentNameFromFiber from 'react-reconciler/src/getComponentNameFromFiber'; | 61 | 63 |
| @@ -91,6 +93,7 @@ import { | 91 | 93 | REACT_OFFSCREEN_TYPE, | 92 | 94 | REACT_LEGACY_HIDDEN_TYPE, | 93 | 95 | REACT_CACHE_TYPE, | | 96 | + REACT_TRACING_MARKER_TYPE, | 94 | 97 | } from 'shared/ReactSymbols'; | 95 | 98 |
| 96 | 99 | export type {Fiber}; | @@ -521,6 +524,11 @@ export function createFiberFromTypeAndProps( | 521 | 524 | return createFiberFromCache(pendingProps, mode, lanes, key); | 522 | 525 | } | 523 | 526 | // eslint-disable-next-line no-fallthrough | | 527 | + case REACT_TRACING_MARKER_TYPE: | | 528 | + if (enableTransitionTracing) { | | 529 | + return createFiberFromTracingMarker(pendingProps, mode, lanes, key); | | 530 | + } | | 531 | + // eslint-disable-next-line no-fallthrough | 524 | 532 | default: { | 525 | 533 | if (typeof type === 'object' && type !== null) { | 526 | 534 | switch (type.$$typeof) { | @@ -746,6 +754,18 @@ export function createFiberFromCache( | 746 | 754 | return fiber; | 747 | 755 | } | 748 | 756 |
| | 757 | +export function createFiberFromTracingMarker( | | 758 | + pendingProps: any, | | 759 | + mode: TypeOfMode, | | 760 | + lanes: Lanes, | | 761 | + key: null | string, | | 762 | +) { | | 763 | + const fiber = createFiber(TracingMarkerComponent, pendingProps, key, mode); | | 764 | + fiber.elementType = REACT_TRACING_MARKER_TYPE; | | 765 | + fiber.lanes = lanes; | | 766 | + return fiber; | | 767 | +} | | 768 | + | 749 | 769 | export function createFiberFromText( | 750 | 770 | content: string, | 751 | 771 | mode: TypeOfMode, | |
Collapse file Copy file name to clipboardExpand all lines: packages/react-reconciler/src/ReactFiberBeginWork.new.js +27Lines changed: 27 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -61,6 +61,7 @@ import { | 61 | 61 | OffscreenComponent, | 62 | 62 | LegacyHiddenComponent, | 63 | 63 | CacheComponent, | | 64 | + TracingMarkerComponent, | 64 | 65 | } from './ReactWorkTags'; | 65 | 66 | import { | 66 | 67 | NoFlags, | @@ -93,6 +94,7 @@ import { | 93 | 94 | enableSuspenseLayoutEffectSemantics, | 94 | 95 | enableSchedulingProfiler, | 95 | 96 | enablePersistentOffscreenHostContainer, | | 97 | + enableTransitionTracing, | 96 | 98 | } from 'shared/ReactFeatureFlags'; | 97 | 99 | import isArray from 'shared/isArray'; | 98 | 100 | import shallowEqual from 'shared/shallowEqual'; | @@ -898,6 +900,21 @@ function updateCacheComponent( | 898 | 900 | return workInProgress.child; | 899 | 901 | } | 900 | 902 |
| | 903 | +// This should only be called if the name changes | | 904 | +function updateTracingMarkerComponent( | | 905 | + current: Fiber | null, | | 906 | + workInProgress: Fiber, | | 907 | + renderLanes: Lanes, | | 908 | +) { | | 909 | + if (!enableTransitionTracing) { | | 910 | + return null; | | 911 | + } | | 912 | + | | 913 | + const nextChildren = workInProgress.pendingProps.children; | | 914 | + reconcileChildren(current, workInProgress, nextChildren, renderLanes); | | 915 | + return workInProgress.child; | | 916 | +} | | 917 | + | 901 | 918 | function updateFragment( | 902 | 919 | current: Fiber | null, | 903 | 920 | workInProgress: Fiber, | @@ -3900,6 +3917,16 @@ function beginWork( | 3900 | 3917 | } | 3901 | 3918 | break; | 3902 | 3919 | } | | 3920 | + case TracingMarkerComponent: { | | 3921 | + if (enableTransitionTracing) { | | 3922 | + return updateTracingMarkerComponent( | | 3923 | + current, | | 3924 | + workInProgress, | | 3925 | + renderLanes, | | 3926 | + ); | | 3927 | + } | | 3928 | + break; | | 3929 | + } | 3903 | 3930 | } | 3904 | 3931 |
| 3905 | 3932 | throw new Error( | |
Collapse file Copy file name to clipboardExpand all lines: packages/react-reconciler/src/ReactFiberBeginWork.old.js +27Lines changed: 27 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -61,6 +61,7 @@ import { | 61 | 61 | OffscreenComponent, | 62 | 62 | LegacyHiddenComponent, | 63 | 63 | CacheComponent, | | 64 | + TracingMarkerComponent, | 64 | 65 | } from './ReactWorkTags'; | 65 | 66 | import { | 66 | 67 | NoFlags, | @@ -93,6 +94,7 @@ import { | 93 | 94 | enableSuspenseLayoutEffectSemantics, | 94 | 95 | enableSchedulingProfiler, | 95 | 96 | enablePersistentOffscreenHostContainer, | | 97 | + enableTransitionTracing, | 96 | 98 | } from 'shared/ReactFeatureFlags'; | 97 | 99 | import isArray from 'shared/isArray'; | 98 | 100 | import shallowEqual from 'shared/shallowEqual'; | @@ -898,6 +900,21 @@ function updateCacheComponent( | 898 | 900 | return workInProgress.child; | 899 | 901 | } | 900 | 902 |
| | 903 | +// This should only be called if the name changes | | 904 | +function updateTracingMarkerComponent( | | 905 | + current: Fiber | null, | | 906 | + workInProgress: Fiber, | | 907 | + renderLanes: Lanes, | | 908 | +) { | | 909 | + if (!enableTransitionTracing) { | | 910 | + return null; | | 911 | + } | | 912 | + | | 913 | + const nextChildren = workInProgress.pendingProps.children; | | 914 | + reconcileChildren(current, workInProgress, nextChildren, renderLanes); | | 915 | + return workInProgress.child; | | 916 | +} | | 917 | + | 901 | 918 | function updateFragment( | 902 | 919 | current: Fiber | null, | 903 | 920 | workInProgress: Fiber, | @@ -3900,6 +3917,16 @@ function beginWork( | 3900 | 3917 | } | 3901 | 3918 | break; | 3902 | 3919 | } | | 3920 | + case TracingMarkerComponent: { | | 3921 | + if (enableTransitionTracing) { | | 3922 | + return updateTracingMarkerComponent( | | 3923 | + current, | | 3924 | + workInProgress, | | 3925 | + renderLanes, | | 3926 | + ); | | 3927 | + } | | 3928 | + break; | | 3929 | + } | 3903 | 3930 | } | 3904 | 3931 |
| 3905 | 3932 | throw new Error( | |
Collapse file Copy file name to clipboardExpand all lines: packages/react-reconciler/src/ReactWorkTags.js +3-1Lines changed: 3 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -32,7 +32,8 @@ export type WorkTag = | 32 | 32 | | 21 | 33 | 33 | | 22 | 34 | 34 | | 23 | 35 | | - | 24; | | 35 | + | 24 | | 36 | + | 25; | 36 | 37 |
| 37 | 38 | export const FunctionComponent = 0; | 38 | 39 | export const ClassComponent = 1; | @@ -58,3 +59,4 @@ export const ScopeComponent = 21; | 58 | 59 | export const OffscreenComponent = 22; | 59 | 60 | export const LegacyHiddenComponent = 23; | 60 | 61 | export const CacheComponent = 24; | | 62 | +export const TracingMarkerComponent = 25; |
Collapse file Copy file name to clipboardExpand all lines: packages/react-reconciler/src/getComponentNameFromFiber.js +3-1Lines changed: 3 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -34,6 +34,7 @@ import { | 34 | 34 | OffscreenComponent, | 35 | 35 | LegacyHiddenComponent, | 36 | 36 | CacheComponent, | | 37 | + TracingMarkerComponent, | 37 | 38 | } from 'react-reconciler/src/ReactWorkTags'; | 38 | 39 | import getComponentNameFromType from 'shared/getComponentNameFromType'; | 39 | 40 | import {REACT_STRICT_MODE_TYPE} from 'shared/ReactSymbols'; | @@ -103,7 +104,8 @@ export default function getComponentNameFromFiber(fiber: Fiber): string | null { | 103 | 104 | return 'Suspense'; | 104 | 105 | case SuspenseListComponent: | 105 | 106 | return 'SuspenseList'; | 106 | | - | | 107 | + case TracingMarkerComponent: | | 108 | + return 'TracingMarker'; | 107 | 109 | // The display name for this tags come from the user-provided type: | 108 | 110 | case ClassComponent: | 109 | 111 | case FunctionComponent: | |
|