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 ,
@@ -178,17 +180,50 @@ export function getInternalReactConstants(
178
180
ForwardRef : 11 ,
179
181
Fragment : 7 ,
180
182
FunctionComponent : 0 ,
183
+ FundamentalComponent : 20 , // Experimental
181
184
HostComponent : 5 ,
182
185
HostPortal : 4 ,
183
186
HostRoot : 3 ,
184
187
HostText : 6 ,
185
188
IncompleteClassComponent : 17 ,
186
189
IndeterminateComponent : 2 ,
187
190
LazyComponent : 16 ,
191
+ LegacyHiddenComponent : 23 ,
188
192
MemoComponent : 14 ,
189
193
Mode : 8 ,
190
194
OffscreenComponent : 22 , // Experimental
191
195
Profiler : 12 ,
196
+ ScopeComponent : 21 , // Experimental
197
+ SimpleMemoComponent : 15 ,
198
+ SuspenseComponent : 13 ,
199
+ SuspenseListComponent : 19 , // Experimental
200
+ YieldComponent : - 1 , // Removed
201
+ } ;
202
+ } else if ( gte ( version , '17.0.0-alpha' ) ) {
203
+ ReactTypeOfWork = {
204
+ ClassComponent : 1 ,
205
+ ContextConsumer : 9 ,
206
+ ContextProvider : 10 ,
207
+ CoroutineComponent : - 1 , // Removed
208
+ CoroutineHandlerPhase : - 1 , // Removed
209
+ DehydratedSuspenseComponent : 18 , // Behind a flag
210
+ ForwardRef : 11 ,
211
+ Fragment : 7 ,
212
+ FunctionComponent : 0 ,
213
+ FundamentalComponent : 20 , // Experimental
214
+ HostComponent : 5 ,
215
+ HostPortal : 4 ,
216
+ HostRoot : 3 ,
217
+ HostText : 6 ,
218
+ IncompleteClassComponent : 17 ,
219
+ IndeterminateComponent : 2 ,
220
+ LazyComponent : 16 ,
221
+ LegacyHiddenComponent : 24 ,
222
+ MemoComponent : 14 ,
223
+ Mode : 8 ,
224
+ OffscreenComponent : 23 , // Experimental
225
+ Profiler : 12 ,
226
+ ScopeComponent : 21 , // Experimental
192
227
SimpleMemoComponent : 15 ,
193
228
SuspenseComponent : 13 ,
194
229
SuspenseListComponent : 19 , // Experimental
@@ -205,17 +240,20 @@ export function getInternalReactConstants(
205
240
ForwardRef : 11 ,
206
241
Fragment : 7 ,
207
242
FunctionComponent : 0 ,
243
+ FundamentalComponent : - 1 , // Experimental
208
244
HostComponent : 5 ,
209
245
HostPortal : 4 ,
210
246
HostRoot : 3 ,
211
247
HostText : 6 ,
212
248
IncompleteClassComponent : 17 ,
213
249
IndeterminateComponent : 2 ,
214
250
LazyComponent : 16 ,
251
+ LegacyHiddenComponent : - 1 ,
215
252
MemoComponent : 14 ,
216
253
Mode : 8 ,
217
254
OffscreenComponent : - 1 , // Experimental
218
255
Profiler : 12 ,
256
+ ScopeComponent : - 1 , // Experimental
219
257
SimpleMemoComponent : 15 ,
220
258
SuspenseComponent : 13 ,
221
259
SuspenseListComponent : 19 , // Experimental
@@ -232,17 +270,20 @@ export function getInternalReactConstants(
232
270
ForwardRef : 13 ,
233
271
Fragment : 9 ,
234
272
FunctionComponent : 0 ,
273
+ FundamentalComponent : - 1 , // Experimental
235
274
HostComponent : 7 ,
236
275
HostPortal : 6 ,
237
276
HostRoot : 5 ,
238
277
HostText : 8 ,
239
278
IncompleteClassComponent : - 1 , // Doesn't exist yet
240
279
IndeterminateComponent : 4 ,
241
280
LazyComponent : - 1 , // Doesn't exist yet
281
+ LegacyHiddenComponent : - 1 ,
242
282
MemoComponent : - 1 , // Doesn't exist yet
243
283
Mode : 10 ,
244
284
OffscreenComponent : - 1 , // Experimental
245
285
Profiler : 15 ,
286
+ ScopeComponent : - 1 , // Experimental
246
287
SimpleMemoComponent : - 1 , // Doesn't exist yet
247
288
SuspenseComponent : 16 ,
248
289
SuspenseListComponent : - 1 , // Doesn't exist yet
@@ -259,17 +300,20 @@ export function getInternalReactConstants(
259
300
ForwardRef : 14 ,
260
301
Fragment : 10 ,
261
302
FunctionComponent : 1 ,
303
+ FundamentalComponent : - 1 , // Experimental
262
304
HostComponent : 5 ,
263
305
HostPortal : 4 ,
264
306
HostRoot : 3 ,
265
307
HostText : 6 ,
266
308
IncompleteClassComponent : - 1 , // Doesn't exist yet
267
309
IndeterminateComponent : 0 ,
268
310
LazyComponent : - 1 , // Doesn't exist yet
311
+ LegacyHiddenComponent : - 1 ,
269
312
MemoComponent : - 1 , // Doesn't exist yet
270
313
Mode : 11 ,
271
314
OffscreenComponent : - 1 , // Experimental
272
315
Profiler : 15 ,
316
+ ScopeComponent : - 1 , // Experimental
273
317
SimpleMemoComponent : - 1 , // Doesn't exist yet
274
318
SuspenseComponent : 16 ,
275
319
SuspenseListComponent : - 1 , // Doesn't exist yet
@@ -301,7 +345,10 @@ export function getInternalReactConstants(
301
345
HostPortal,
302
346
HostText,
303
347
Fragment,
348
+ LazyComponent,
349
+ LegacyHiddenComponent,
304
350
MemoComponent,
351
+ OffscreenComponent,
305
352
SimpleMemoComponent,
306
353
SuspenseComponent,
307
354
SuspenseListComponent,
@@ -354,11 +401,17 @@ export function getInternalReactConstants(
354
401
case HostText :
355
402
case Fragment :
356
403
return null ;
404
+ case LazyComponent :
405
+ return 'Lazy' ;
357
406
case MemoComponent :
358
407
case SimpleMemoComponent :
359
408
return getDisplayName ( resolvedType , 'Anonymous' ) ;
360
409
case SuspenseComponent :
361
410
return 'Suspense' ;
411
+ case LegacyHiddenComponent :
412
+ return 'LegacyHidden' ;
413
+ case OffscreenComponent :
414
+ return 'Offscreen' ;
362
415
case SuspenseListComponent :
363
416
return 'SuspenseList' ;
364
417
default :
@@ -493,10 +546,14 @@ export function attach(
493
546
494
547
const debug = ( name : string , fiber : Fiber , parentFiber : ?Fiber ) : void => {
495
548
if ( __DEBUG__ ) {
496
- const displayName = getDisplayNameForFiber ( fiber ) || 'null' ;
549
+ const displayName =
550
+ fiber . tag + ':' + ( getDisplayNameForFiber ( fiber ) || 'null' ) ;
497
551
const id = getFiberID ( fiber ) ;
498
- const parentDisplayName =
499
- ( parentFiber != null && getDisplayNameForFiber ( parentFiber ) ) || 'null' ;
552
+ const parentDisplayName = parentFiber
553
+ ? parentFiber . tag +
554
+ ':' +
555
+ ( getDisplayNameForFiber ( parentFiber ) || 'null' )
556
+ : '' ;
500
557
const parentID = parentFiber ? getFiberID ( parentFiber ) : '' ;
501
558
// NOTE: calling getFiberID or getPrimaryFiber is unsafe here
502
559
// because it will put them in the map. For now, we'll omit them.
@@ -1207,6 +1264,7 @@ export function attach(
1207
1264
return ;
1208
1265
}
1209
1266
const id = getFiberID ( primaryFiber ) ;
1267
+
1210
1268
if ( isRoot ) {
1211
1269
// Roots must be removed only after all children (pending and simulated) have been removed.
1212
1270
// So we track it separately.
0 commit comments