7
* @flow
8
*/
9
10
-import {gte} from 'semver';
10
+import {gt, gte} from 'semver';
11
import {
12
ComponentFilterDisplayName,
13
ComponentFilterElementType,
166
// **********************************************************
167
// The section below is copied from files in React repo.
168
// Keep it in sync, and add version guards if it changes.
169
- if (gte(version, '17.0.0-alpha')) {
170
- // TODO (Offscreen) Update the version number above to reflect the first Offscreen alpha/beta release.
169
+ //
170
+ // TODO Update the gt() check below to be gte() whichever the next version number is.
171
+ // Currently the version in Git is 17.0.2 (but that version has not been/may not end up being released).
172
+ if (gt(version, '17.0.1')) {
173
ReactTypeOfWork = {
174
ClassComponent: 1,
175
ContextConsumer: 9,
187
IncompleteClassComponent: 17,
188
IndeterminateComponent: 2,
189
LazyComponent: 16,
190
+ LegacyHiddenComponent: 23,
191
MemoComponent: 14,
192
Mode: 8,
193
OffscreenComponent: 22, // Experimental
194
Profiler: 12,
195
+ ScopeComponent: 21, // Experimental
196
+ SimpleMemoComponent: 15,
197
+ SuspenseComponent: 13,
198
+ SuspenseListComponent: 19, // Experimental
199
+ YieldComponent: -1, // Removed
200
+ };
201
+ } else if (gte(version, '17.0.0-alpha')) {
202
+ ReactTypeOfWork = {
203
+ ClassComponent: 1,
204
+ ContextConsumer: 9,
205
+ ContextProvider: 10,
206
+ CoroutineComponent: -1, // Removed
207
+ CoroutineHandlerPhase: -1, // Removed
208
+ DehydratedSuspenseComponent: 18, // Behind a flag
209
+ ForwardRef: 11,
210
+ Fragment: 7,
211
+ FunctionComponent: 0,
212
+ HostComponent: 5,
213
+ HostPortal: 4,
214
+ HostRoot: 3,
215
+ HostText: 6,
216
+ IncompleteClassComponent: 17,
217
+ IndeterminateComponent: 2,
218
+ LazyComponent: 16,
219
+ LegacyHiddenComponent: 24,
220
+ MemoComponent: 14,
221
+ Mode: 8,
222
+ OffscreenComponent: 23, // Experimental
223
+ Profiler: 12,
224
+ ScopeComponent: 21, // Experimental
225
SimpleMemoComponent: 15,
226
SuspenseComponent: 13,
227
SuspenseListComponent: 19, // Experimental
245
IncompleteClassComponent: 17,
246
IndeterminateComponent: 2,
247
LazyComponent: 16,
248
+ LegacyHiddenComponent: -1,
249
MemoComponent: 14,
250
Mode: 8,
251
OffscreenComponent: -1, // Experimental
252
Profiler: 12,
253
+ ScopeComponent: -1, // Experimental
254
SimpleMemoComponent: 15,
255
SuspenseComponent: 13,
256
SuspenseListComponent: 19, // Experimental
274
IncompleteClassComponent: -1, // Doesn't exist yet
275
IndeterminateComponent: 4,
276
LazyComponent: -1, // Doesn't exist yet
277
+ LegacyHiddenComponent: -1,
278
MemoComponent: -1, // Doesn't exist yet
279
Mode: 10,
280
OffscreenComponent: -1, // Experimental
281
Profiler: 15,
282
+ ScopeComponent: -1, // Experimental
283
SimpleMemoComponent: -1, // Doesn't exist yet
284
SuspenseComponent: 16,
285
SuspenseListComponent: -1, // Doesn't exist yet
303
IncompleteClassComponent: -1, // Doesn't exist yet
304
IndeterminateComponent: 0,
305
LazyComponent: -1, // Doesn't exist yet
306
+ LegacyHiddenComponent: -1,
307
MemoComponent: -1, // Doesn't exist yet
308
Mode: 11,
309
OffscreenComponent: -1, // Experimental
310
Profiler: 15,
311
+ ScopeComponent: -1, // Experimental
312
SimpleMemoComponent: -1, // Doesn't exist yet
313
SuspenseComponent: 16,
314
SuspenseListComponent: -1, // Doesn't exist yet
340
HostPortal,
341
HostText,
342
Fragment,
343
+ LazyComponent,
344
+ LegacyHiddenComponent,
345
MemoComponent,
346
+ OffscreenComponent,
347
+ ScopeComponent,
348
SimpleMemoComponent,
349
SuspenseComponent,
350
SuspenseListComponent,
397
case HostText:
398
case Fragment:
399
return null;
400
+ case LazyComponent:
401
+ // This display name will not be user visible.
402
+ // Once a Lazy component loads its inner component, React replaces the tag and type.
403
+ // This display name will only show up in console logs when DevTools DEBUG mode is on.
404
+ return 'Lazy';
405
case MemoComponent:
406
case SimpleMemoComponent:
407
return getDisplayName(resolvedType, 'Anonymous');
408
case SuspenseComponent:
409
return 'Suspense';
410
+ case LegacyHiddenComponent:
411
+ return 'LegacyHidden';
412
+ case OffscreenComponent:
413
+ return 'Offscreen';
414
+ case ScopeComponent:
415
+ return 'Scope';
416
case SuspenseListComponent:
417
return 'SuspenseList';
418
default:
547
548
const debug = (name: string, fiber: Fiber, parentFiber: ?Fiber): void => {
549
if (__DEBUG__) {
496
- const displayName = getDisplayNameForFiber(fiber) || 'null';
550
+ const displayName =
551
+ fiber.tag + ':' + (getDisplayNameForFiber(fiber) || 'null');
552
const id = getFiberID(fiber);
498
- const parentDisplayName =
499
- (parentFiber != null && getDisplayNameForFiber(parentFiber)) || 'null';
553
+ const parentDisplayName = parentFiber
554
+ ? parentFiber.tag +
555
+ ':' +
556
+ (getDisplayNameForFiber(parentFiber) || 'null')
557
+ : '';
558
const parentID = parentFiber ? getFiberID(parentFiber) : '';
559
// NOTE: calling getFiberID or getPrimaryFiber is unsafe here
560
// because it will put them in the map. For now, we'll omit them.
1265
return;
1266
}
1267
const id = getFiberID(primaryFiber);
1268
+
1269
if (isRoot) {
1270
// Roots must be removed only after all children (pending and simulated) have been removed.
1271
// So we track it separately.