|
7 | 7 | * @flow
|
8 | 8 | */
|
9 | 9 |
|
10 |
| -import {gte} from 'semver'; |
| 10 | +import {gt, gte} from 'semver'; |
11 | 11 | import {
|
12 | 12 | ComponentFilterDisplayName,
|
13 | 13 | ComponentFilterElementType,
|
@@ -153,7 +153,8 @@ export function getInternalReactConstants(
|
153 | 153 | // **********************************************************
|
154 | 154 | // The section below is copied from files in React repo.
|
155 | 155 | // Keep it in sync, and add version guards if it changes.
|
156 |
| - if (gte(version, '16.6.0-beta.0')) { |
| 156 | + if (gt(version, '16.13.1')) { |
| 157 | + // TODO (Offscreen) Update the version number above to reflect the first Offscreen alpha/beta release. |
157 | 158 | ReactTypeOfWork = {
|
158 | 159 | Block: 22,
|
159 | 160 | ClassComponent: 1,
|
@@ -181,6 +182,34 @@ export function getInternalReactConstants(
|
181 | 182 | SuspenseListComponent: 19, // Experimental
|
182 | 183 | YieldComponent: -1, // Removed
|
183 | 184 | };
|
| 185 | + } else if (gte(version, '16.6.0-beta.0')) { |
| 186 | + ReactTypeOfWork = { |
| 187 | + Block: 22, |
| 188 | + ClassComponent: 1, |
| 189 | + ContextConsumer: 9, |
| 190 | + ContextProvider: 10, |
| 191 | + CoroutineComponent: -1, // Removed |
| 192 | + CoroutineHandlerPhase: -1, // Removed |
| 193 | + DehydratedSuspenseComponent: 18, // Behind a flag |
| 194 | + ForwardRef: 11, |
| 195 | + Fragment: 7, |
| 196 | + FunctionComponent: 0, |
| 197 | + HostComponent: 5, |
| 198 | + HostPortal: 4, |
| 199 | + HostRoot: 3, |
| 200 | + HostText: 6, |
| 201 | + IncompleteClassComponent: 17, |
| 202 | + IndeterminateComponent: 2, |
| 203 | + LazyComponent: 16, |
| 204 | + MemoComponent: 14, |
| 205 | + Mode: 8, |
| 206 | + OffscreenComponent: -1, // Experimental |
| 207 | + Profiler: 12, |
| 208 | + SimpleMemoComponent: 15, |
| 209 | + SuspenseComponent: 13, |
| 210 | + SuspenseListComponent: 19, // Experimental |
| 211 | + YieldComponent: -1, // Removed |
| 212 | + }; |
184 | 213 | } else if (gte(version, '16.4.3-alpha')) {
|
185 | 214 | ReactTypeOfWork = {
|
186 | 215 | Block: -1, // Doesn't exist yet
|
@@ -452,14 +481,16 @@ export function attach(
|
452 | 481 | const debug = (name: string, fiber: Fiber, parentFiber: ?Fiber): void => {
|
453 | 482 | if (__DEBUG__) {
|
454 | 483 | const displayName = getDisplayNameForFiber(fiber) || 'null';
|
| 484 | + const id = getFiberID(fiber); |
455 | 485 | const parentDisplayName =
|
456 | 486 | (parentFiber != null && getDisplayNameForFiber(parentFiber)) || 'null';
|
| 487 | + const parentID = parentFiber ? getFiberID(parentFiber) : ''; |
457 | 488 | // NOTE: calling getFiberID or getPrimaryFiber is unsafe here
|
458 | 489 | // because it will put them in the map. For now, we'll omit them.
|
459 | 490 | // TODO: better debugging story for this.
|
460 | 491 | console.log(
|
461 |
| - `[renderer] %c${name} %c${displayName} %c${ |
462 |
| - parentFiber ? parentDisplayName : '' |
| 492 | + `[renderer] %c${name} %c${displayName} (${id}) %c${ |
| 493 | + parentFiber ? `${parentDisplayName} (${parentID})` : '' |
463 | 494 | }`,
|
464 | 495 | 'color: red; font-weight: bold;',
|
465 | 496 | 'color: blue;',
|
@@ -1076,6 +1107,10 @@ export function attach(
|
1076 | 1107 | }
|
1077 | 1108 |
|
1078 | 1109 | function recordMount(fiber: Fiber, parentFiber: Fiber | null) {
|
| 1110 | + if (__DEBUG__) { |
| 1111 | + debug('recordMount()', fiber, parentFiber); |
| 1112 | + } |
| 1113 | + |
1079 | 1114 | const isRoot = fiber.tag === HostRoot;
|
1080 | 1115 | const id = getFiberID(getPrimaryFiber(fiber));
|
1081 | 1116 |
|
@@ -1130,6 +1165,10 @@ export function attach(
|
1130 | 1165 | }
|
1131 | 1166 |
|
1132 | 1167 | function recordUnmount(fiber: Fiber, isSimulated: boolean) {
|
| 1168 | + if (__DEBUG__) { |
| 1169 | + debug('recordUnmount()', fiber); |
| 1170 | + } |
| 1171 | + |
1133 | 1172 | if (trackedPathMatchFiber !== null) {
|
1134 | 1173 | // We're in the process of trying to restore previous selection.
|
1135 | 1174 | // If this fiber matched but is being unmounted, there's no use trying.
|
@@ -1215,7 +1254,8 @@ export function attach(
|
1215 | 1254 | // because we don't want to highlight every host node inside of a newly mounted subtree.
|
1216 | 1255 | }
|
1217 | 1256 |
|
1218 |
| - if (fiber.tag === ReactTypeOfWork.SuspenseComponent) { |
| 1257 | + const isSuspense = fiber.tag === ReactTypeOfWork.SuspenseComponent; |
| 1258 | + if (isSuspense) { |
1219 | 1259 | const isTimedOut = fiber.memoizedState !== null;
|
1220 | 1260 | if (isTimedOut) {
|
1221 | 1261 | // Special case: if Suspense mounts in a timed-out state,
|
|
0 commit comments