@@ -366,121 +366,123 @@ describe('ReactHooksInspectionIntegration', () => {
366
366
] ) ;
367
367
} ) ;
368
368
369
- if ( __EXPERIMENTAL__ ) {
370
- it ( 'should support composite useTransition hook' , ( ) => {
371
- function Foo ( props ) {
372
- React . useTransition ( ) ;
373
- const memoizedValue = React . useMemo ( ( ) => 'hello' , [ ] ) ;
374
- return < div > { memoizedValue } </ div > ;
375
- }
376
- const renderer = ReactTestRenderer . create ( < Foo /> ) ;
377
- const childFiber = renderer . root . findByType ( Foo ) . _currentFiber ( ) ;
378
- const tree = ReactDebugTools . inspectHooksOfFiber ( childFiber ) ;
379
- expect ( tree ) . toEqual ( [
380
- {
381
- id : 0 ,
382
- isStateEditable : false ,
383
- name : 'Transition' ,
384
- value : undefined ,
385
- subHooks : [ ] ,
386
- } ,
387
- {
388
- id : 1 ,
389
- isStateEditable : false ,
390
- name : 'Memo' ,
391
- value : 'hello' ,
392
- subHooks : [ ] ,
393
- } ,
394
- ] ) ;
395
- } ) ;
396
-
397
- it ( 'should support composite useDeferredValue hook' , ( ) => {
398
- function Foo ( props ) {
399
- React . useDeferredValue ( 'abc' , {
400
- timeoutMs : 500 ,
401
- } ) ;
402
- const [ state ] = React . useState ( ( ) => 'hello' , [ ] ) ;
403
- return < div > { state } </ div > ;
404
- }
405
- const renderer = ReactTestRenderer . create ( < Foo /> ) ;
406
- const childFiber = renderer . root . findByType ( Foo ) . _currentFiber ( ) ;
407
- const tree = ReactDebugTools . inspectHooksOfFiber ( childFiber ) ;
408
- expect ( tree ) . toEqual ( [
409
- {
410
- id : 0 ,
411
- isStateEditable : false ,
412
- name : 'DeferredValue' ,
413
- value : 'abc' ,
414
- subHooks : [ ] ,
415
- } ,
416
- {
417
- id : 1 ,
418
- isStateEditable : true ,
419
- name : 'State' ,
420
- value : 'hello' ,
421
- subHooks : [ ] ,
422
- } ,
423
- ] ) ;
424
- } ) ;
425
-
426
- it ( 'should support composite useOpaqueIdentifier hook' , ( ) => {
427
- function Foo ( props ) {
428
- const id = React . unstable_useOpaqueIdentifier ( ) ;
429
- const [ state ] = React . useState ( ( ) => 'hello' , [ ] ) ;
430
- return < div id = { id } > { state } </ div > ;
431
- }
432
-
433
- const renderer = ReactTestRenderer . create ( < Foo /> ) ;
434
- const childFiber = renderer . root . findByType ( Foo ) . _currentFiber ( ) ;
435
- const tree = ReactDebugTools . inspectHooksOfFiber ( childFiber ) ;
436
-
437
- expect ( tree . length ) . toEqual ( 2 ) ;
438
-
439
- expect ( tree [ 0 ] . id ) . toEqual ( 0 ) ;
440
- expect ( tree [ 0 ] . isStateEditable ) . toEqual ( false ) ;
441
- expect ( tree [ 0 ] . name ) . toEqual ( 'OpaqueIdentifier' ) ;
442
- expect ( ( tree [ 0 ] . value + '' ) . startsWith ( 'c_' ) ) . toBe ( true ) ;
369
+ // @gate experimental
370
+ it ( 'should support composite useTransition hook' , ( ) => {
371
+ function Foo ( props ) {
372
+ React . unstable_useTransition ( ) ;
373
+ const memoizedValue = React . useMemo ( ( ) => 'hello' , [ ] ) ;
374
+ return < div > { memoizedValue } </ div > ;
375
+ }
376
+ const renderer = ReactTestRenderer . create ( < Foo /> ) ;
377
+ const childFiber = renderer . root . findByType ( Foo ) . _currentFiber ( ) ;
378
+ const tree = ReactDebugTools . inspectHooksOfFiber ( childFiber ) ;
379
+ expect ( tree ) . toEqual ( [
380
+ {
381
+ id : 0 ,
382
+ isStateEditable : false ,
383
+ name : 'Transition' ,
384
+ value : undefined ,
385
+ subHooks : [ ] ,
386
+ } ,
387
+ {
388
+ id : 1 ,
389
+ isStateEditable : false ,
390
+ name : 'Memo' ,
391
+ value : 'hello' ,
392
+ subHooks : [ ] ,
393
+ } ,
394
+ ] ) ;
395
+ } ) ;
443
396
444
- expect ( tree [ 1 ] ) . toEqual ( {
397
+ // @gate experimental
398
+ it ( 'should support composite useDeferredValue hook' , ( ) => {
399
+ function Foo ( props ) {
400
+ React . unstable_useDeferredValue ( 'abc' , {
401
+ timeoutMs : 500 ,
402
+ } ) ;
403
+ const [ state ] = React . useState ( ( ) => 'hello' , [ ] ) ;
404
+ return < div > { state } </ div > ;
405
+ }
406
+ const renderer = ReactTestRenderer . create ( < Foo /> ) ;
407
+ const childFiber = renderer . root . findByType ( Foo ) . _currentFiber ( ) ;
408
+ const tree = ReactDebugTools . inspectHooksOfFiber ( childFiber ) ;
409
+ expect ( tree ) . toEqual ( [
410
+ {
411
+ id : 0 ,
412
+ isStateEditable : false ,
413
+ name : 'DeferredValue' ,
414
+ value : 'abc' ,
415
+ subHooks : [ ] ,
416
+ } ,
417
+ {
445
418
id : 1 ,
446
419
isStateEditable : true ,
447
420
name : 'State' ,
448
421
value : 'hello' ,
449
422
subHooks : [ ] ,
450
- } ) ;
423
+ } ,
424
+ ] ) ;
425
+ } ) ;
426
+
427
+ // @gate experimental
428
+ it ( 'should support composite useOpaqueIdentifier hook' , ( ) => {
429
+ function Foo ( props ) {
430
+ const id = React . unstable_useOpaqueIdentifier ( ) ;
431
+ const [ state ] = React . useState ( ( ) => 'hello' , [ ] ) ;
432
+ return < div id = { id } > { state } </ div > ;
433
+ }
434
+
435
+ const renderer = ReactTestRenderer . create ( < Foo /> ) ;
436
+ const childFiber = renderer . root . findByType ( Foo ) . _currentFiber ( ) ;
437
+ const tree = ReactDebugTools . inspectHooksOfFiber ( childFiber ) ;
438
+
439
+ expect ( tree . length ) . toEqual ( 2 ) ;
440
+
441
+ expect ( tree [ 0 ] . id ) . toEqual ( 0 ) ;
442
+ expect ( tree [ 0 ] . isStateEditable ) . toEqual ( false ) ;
443
+ expect ( tree [ 0 ] . name ) . toEqual ( 'OpaqueIdentifier' ) ;
444
+ expect ( ( tree [ 0 ] . value + '' ) . startsWith ( 'c_' ) ) . toBe ( true ) ;
445
+
446
+ expect ( tree [ 1 ] ) . toEqual ( {
447
+ id : 1 ,
448
+ isStateEditable : true ,
449
+ name : 'State' ,
450
+ value : 'hello' ,
451
+ subHooks : [ ] ,
451
452
} ) ;
453
+ } ) ;
452
454
453
- it ( 'should support composite useOpaqueIdentifier hook in concurrent mode' , ( ) => {
454
- function Foo ( props ) {
455
- const id = React . unstable_useOpaqueIdentifier ( ) ;
456
- const [ state ] = React . useState ( ( ) => 'hello' , [ ] ) ;
457
- return < div id = { id } > { state } </ div > ;
458
- }
455
+ // @gate experimental
456
+ it ( 'should support composite useOpaqueIdentifier hook in concurrent mode' , ( ) => {
457
+ function Foo ( props ) {
458
+ const id = React . unstable_useOpaqueIdentifier ( ) ;
459
+ const [ state ] = React . useState ( ( ) => 'hello' , [ ] ) ;
460
+ return < div id = { id } > { state } </ div > ;
461
+ }
459
462
460
- const renderer = ReactTestRenderer . create ( < Foo /> , {
461
- unstable_isConcurrent : true ,
462
- } ) ;
463
- expect ( Scheduler ) . toFlushWithoutYielding ( ) ;
463
+ const renderer = ReactTestRenderer . create ( < Foo /> , {
464
+ unstable_isConcurrent : true ,
465
+ } ) ;
466
+ expect ( Scheduler ) . toFlushWithoutYielding ( ) ;
464
467
465
- const childFiber = renderer . root . findByType ( Foo ) . _currentFiber ( ) ;
466
- const tree = ReactDebugTools . inspectHooksOfFiber ( childFiber ) ;
468
+ const childFiber = renderer . root . findByType ( Foo ) . _currentFiber ( ) ;
469
+ const tree = ReactDebugTools . inspectHooksOfFiber ( childFiber ) ;
467
470
468
- expect ( tree . length ) . toEqual ( 2 ) ;
471
+ expect ( tree . length ) . toEqual ( 2 ) ;
469
472
470
- expect ( tree [ 0 ] . id ) . toEqual ( 0 ) ;
471
- expect ( tree [ 0 ] . isStateEditable ) . toEqual ( false ) ;
472
- expect ( tree [ 0 ] . name ) . toEqual ( 'OpaqueIdentifier' ) ;
473
- expect ( ( tree [ 0 ] . value + '' ) . startsWith ( 'c_' ) ) . toBe ( true ) ;
473
+ expect ( tree [ 0 ] . id ) . toEqual ( 0 ) ;
474
+ expect ( tree [ 0 ] . isStateEditable ) . toEqual ( false ) ;
475
+ expect ( tree [ 0 ] . name ) . toEqual ( 'OpaqueIdentifier' ) ;
476
+ expect ( ( tree [ 0 ] . value + '' ) . startsWith ( 'c_' ) ) . toBe ( true ) ;
474
477
475
- expect ( tree [ 1 ] ) . toEqual ( {
476
- id : 1 ,
477
- isStateEditable : true ,
478
- name : 'State' ,
479
- value : 'hello' ,
480
- subHooks : [ ] ,
481
- } ) ;
478
+ expect ( tree [ 1 ] ) . toEqual ( {
479
+ id : 1 ,
480
+ isStateEditable : true ,
481
+ name : 'State' ,
482
+ value : 'hello' ,
483
+ subHooks : [ ] ,
482
484
} ) ;
483
- }
485
+ } ) ;
484
486
485
487
describe ( 'useDebugValue' , ( ) => {
486
488
it ( 'should support inspectable values for multiple custom hooks' , ( ) => {
0 commit comments