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 ,
@@ -166,8 +166,10 @@ export function getInternalReactConstants(
166
166
// **********************************************************
167
167
// The section below is copied from files in React repo.
168
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' ) ) {
171
173
ReactTypeOfWork = {
172
174
ClassComponent : 1 ,
173
175
ContextConsumer : 9 ,
@@ -185,10 +187,41 @@ export function getInternalReactConstants(
185
187
IncompleteClassComponent : 17 ,
186
188
IndeterminateComponent : 2 ,
187
189
LazyComponent : 16 ,
190
+ LegacyHiddenComponent : 23 ,
188
191
MemoComponent : 14 ,
189
192
Mode : 8 ,
190
193
OffscreenComponent : 22 , // Experimental
191
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
192
225
SimpleMemoComponent : 15 ,
193
226
SuspenseComponent : 13 ,
194
227
SuspenseListComponent : 19 , // Experimental
@@ -212,10 +245,12 @@ export function getInternalReactConstants(
212
245
IncompleteClassComponent : 17 ,
213
246
IndeterminateComponent : 2 ,
214
247
LazyComponent : 16 ,
248
+ LegacyHiddenComponent : - 1 ,
215
249
MemoComponent : 14 ,
216
250
Mode : 8 ,
217
251
OffscreenComponent : - 1 , // Experimental
218
252
Profiler : 12 ,
253
+ ScopeComponent : - 1 , // Experimental
219
254
SimpleMemoComponent : 15 ,
220
255
SuspenseComponent : 13 ,
221
256
SuspenseListComponent : 19 , // Experimental
@@ -239,10 +274,12 @@ export function getInternalReactConstants(
239
274
IncompleteClassComponent : - 1 , // Doesn't exist yet
240
275
IndeterminateComponent : 4 ,
241
276
LazyComponent : - 1 , // Doesn't exist yet
277
+ LegacyHiddenComponent : - 1 ,
242
278
MemoComponent : - 1 , // Doesn't exist yet
243
279
Mode : 10 ,
244
280
OffscreenComponent : - 1 , // Experimental
245
281
Profiler : 15 ,
282
+ ScopeComponent : - 1 , // Experimental
246
283
SimpleMemoComponent : - 1 , // Doesn't exist yet
247
284
SuspenseComponent : 16 ,
248
285
SuspenseListComponent : - 1 , // Doesn't exist yet
@@ -266,10 +303,12 @@ export function getInternalReactConstants(
266
303
IncompleteClassComponent : - 1 , // Doesn't exist yet
267
304
IndeterminateComponent : 0 ,
268
305
LazyComponent : - 1 , // Doesn't exist yet
306
+ LegacyHiddenComponent : - 1 ,
269
307
MemoComponent : - 1 , // Doesn't exist yet
270
308
Mode : 11 ,
271
309
OffscreenComponent : - 1 , // Experimental
272
310
Profiler : 15 ,
311
+ ScopeComponent : - 1 , // Experimental
273
312
SimpleMemoComponent : - 1 , // Doesn't exist yet
274
313
SuspenseComponent : 16 ,
275
314
SuspenseListComponent : - 1 , // Doesn't exist yet
@@ -301,7 +340,11 @@ export function getInternalReactConstants(
301
340
HostPortal,
302
341
HostText,
303
342
Fragment,
343
+ LazyComponent,
344
+ LegacyHiddenComponent,
304
345
MemoComponent,
346
+ OffscreenComponent,
347
+ ScopeComponent,
305
348
SimpleMemoComponent,
306
349
SuspenseComponent,
307
350
SuspenseListComponent,
@@ -354,11 +397,22 @@ export function getInternalReactConstants(
354
397
case HostText :
355
398
case Fragment :
356
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' ;
357
405
case MemoComponent :
358
406
case SimpleMemoComponent :
359
407
return getDisplayName ( resolvedType , 'Anonymous' ) ;
360
408
case SuspenseComponent :
361
409
return 'Suspense' ;
410
+ case LegacyHiddenComponent :
411
+ return 'LegacyHidden' ;
412
+ case OffscreenComponent :
413
+ return 'Offscreen' ;
414
+ case ScopeComponent :
415
+ return 'Scope' ;
362
416
case SuspenseListComponent :
363
417
return 'SuspenseList' ;
364
418
default :
@@ -493,10 +547,14 @@ export function attach(
493
547
494
548
const debug = ( name : string , fiber : Fiber , parentFiber : ?Fiber ) : void => {
495
549
if ( __DEBUG__ ) {
496
- const displayName = getDisplayNameForFiber ( fiber ) || 'null' ;
550
+ const displayName =
551
+ fiber . tag + ':' + ( getDisplayNameForFiber ( fiber ) || 'null' ) ;
497
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
+ : '' ;
500
558
const parentID = parentFiber ? getFiberID ( parentFiber ) : '' ;
501
559
// NOTE: calling getFiberID or getPrimaryFiber is unsafe here
502
560
// because it will put them in the map. For now, we'll omit them.
@@ -1207,6 +1265,7 @@ export function attach(
1207
1265
return ;
1208
1266
}
1209
1267
const id = getFiberID ( primaryFiber ) ;
1268
+
1210
1269
if ( isRoot ) {
1211
1270
// Roots must be removed only after all children (pending and simulated) have been removed.
1212
1271
// So we track it separately.
0 commit comments