@@ -959,12 +959,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
959
959
expect ( Scheduler ) . toFlushAndYield ( [ 'S' ] ) ;
960
960
961
961
// Schedule an update, and suspend for up to 5 seconds.
962
- React . unstable_withSuspenseConfig (
963
- ( ) => ReactNoop . render ( < App text = "A" /> ) ,
964
- {
965
- timeoutMs : 5000 ,
966
- } ,
967
- ) ;
962
+ React . unstable_startTransition ( ( ) => ReactNoop . render ( < App text = "A" /> ) ) ;
968
963
// The update should suspend.
969
964
expect ( Scheduler ) . toFlushAndYield ( [ 'Suspend! [A]' , 'Loading...' ] ) ;
970
965
expect ( ReactNoop . getChildren ( ) ) . toEqual ( [ span ( 'S' ) ] ) ;
@@ -976,12 +971,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
976
971
expect ( ReactNoop . getChildren ( ) ) . toEqual ( [ span ( 'S' ) ] ) ;
977
972
978
973
// Schedule another low priority update.
979
- React . unstable_withSuspenseConfig (
980
- ( ) => ReactNoop . render ( < App text = "B" /> ) ,
981
- {
982
- timeoutMs : 10000 ,
983
- } ,
984
- ) ;
974
+ React . unstable_startTransition ( ( ) => ReactNoop . render ( < App text = "B" /> ) ) ;
985
975
// This update should also suspend.
986
976
expect ( Scheduler ) . toFlushAndYield ( [ 'Suspend! [B]' , 'Loading...' ] ) ;
987
977
expect ( ReactNoop . getChildren ( ) ) . toEqual ( [ span ( 'S' ) ] ) ;
@@ -2282,7 +2272,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
2282
2272
ReactNoop . render ( < Foo renderContent = { 1 } /> ) ;
2283
2273
2284
2274
// Took a long time to render. This is to ensure we get a long suspense time.
2285
- // Could also use something like withSuspenseConfig to simulate this.
2275
+ // Could also use something like startTransition to simulate this.
2286
2276
Scheduler . unstable_advanceTime ( 1500 ) ;
2287
2277
await advanceTimers ( 1500 ) ;
2288
2278
@@ -2330,10 +2320,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
2330
2320
}
2331
2321
2332
2322
// Initial render.
2333
- React . unstable_withSuspenseConfig (
2334
- ( ) => ReactNoop . render ( < App page = "A" /> ) ,
2335
- SUSPENSE_CONFIG ,
2336
- ) ;
2323
+ React . unstable_startTransition ( ( ) => ReactNoop . render ( < App page = "A" /> ) ) ;
2337
2324
2338
2325
expect ( Scheduler ) . toFlushAndYield ( [ 'Suspend! [A]' , 'Loading...' ] ) ;
2339
2326
// Only a short time is needed to unsuspend the initial loading state.
@@ -2349,10 +2336,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
2349
2336
expect ( ReactNoop . getChildren ( ) ) . toEqual ( [ span ( 'A' ) ] ) ;
2350
2337
2351
2338
// Start transition.
2352
- React . unstable_withSuspenseConfig (
2353
- ( ) => ReactNoop . render ( < App page = "B" /> ) ,
2354
- SUSPENSE_CONFIG ,
2355
- ) ;
2339
+ React . unstable_startTransition ( ( ) => ReactNoop . render ( < App page = "B" /> ) ) ;
2356
2340
2357
2341
expect ( Scheduler ) . toFlushAndYield ( [ 'Suspend! [B]' , 'Loading...' ] ) ;
2358
2342
Scheduler . unstable_advanceTime ( 100000 ) ;
@@ -2389,10 +2373,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
2389
2373
2390
2374
// Initial render.
2391
2375
await ReactNoop . act ( async ( ) => {
2392
- React . unstable_withSuspenseConfig (
2393
- ( ) => transitionToPage ( 'A' ) ,
2394
- SUSPENSE_CONFIG ,
2395
- ) ;
2376
+ React . unstable_startTransition ( ( ) => transitionToPage ( 'A' ) ) ;
2396
2377
2397
2378
expect ( Scheduler ) . toFlushAndYield ( [ 'Suspend! [A]' , 'Loading...' ] ) ;
2398
2379
// Only a short time is needed to unsuspend the initial loading state.
@@ -2409,10 +2390,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
2409
2390
2410
2391
// Start transition.
2411
2392
await ReactNoop . act ( async ( ) => {
2412
- React . unstable_withSuspenseConfig (
2413
- ( ) => transitionToPage ( 'B' ) ,
2414
- SUSPENSE_CONFIG ,
2415
- ) ;
2393
+ React . unstable_startTransition ( ( ) => transitionToPage ( 'B' ) ) ;
2416
2394
2417
2395
expect ( Scheduler ) . toFlushAndYield ( [ 'Suspend! [B]' , 'Loading...' ] ) ;
2418
2396
Scheduler . unstable_advanceTime ( 100000 ) ;
@@ -2452,10 +2430,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
2452
2430
2453
2431
// Initial render.
2454
2432
await ReactNoop . act ( async ( ) => {
2455
- React . unstable_withSuspenseConfig (
2456
- ( ) => transitionToPage ( 'A' ) ,
2457
- SUSPENSE_CONFIG ,
2458
- ) ;
2433
+ React . unstable_startTransition ( ( ) => transitionToPage ( 'A' ) ) ;
2459
2434
2460
2435
expect ( Scheduler ) . toFlushAndYield ( [ 'Suspend! [A]' , 'Loading...' ] ) ;
2461
2436
// Only a short time is needed to unsuspend the initial loading state.
@@ -2472,10 +2447,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
2472
2447
2473
2448
// Start transition.
2474
2449
await ReactNoop . act ( async ( ) => {
2475
- React . unstable_withSuspenseConfig (
2476
- ( ) => transitionToPage ( 'B' ) ,
2477
- SUSPENSE_CONFIG ,
2478
- ) ;
2450
+ React . unstable_startTransition ( ( ) => transitionToPage ( 'B' ) ) ;
2479
2451
2480
2452
expect ( Scheduler ) . toFlushAndYield ( [ 'Suspend! [B]' , 'Loading...' ] ) ;
2481
2453
Scheduler . unstable_advanceTime ( 100000 ) ;
@@ -2689,75 +2661,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
2689
2661
} ) ;
2690
2662
2691
2663
// @gate experimental
2692
- it ( 'disables suspense config when nothing is passed to withSuspenseConfig' , async ( ) => {
2693
- function App ( { page} ) {
2694
- return (
2695
- < Suspense fallback = { < Text text = "Loading..." /> } >
2696
- < AsyncText text = { page } ms = { 2000 } />
2697
- </ Suspense >
2698
- ) ;
2699
- }
2700
-
2701
- // Initial render.
2702
- ReactNoop . render ( < App page = "A" /> ) ;
2703
- expect ( Scheduler ) . toFlushAndYield ( [ 'Suspend! [A]' , 'Loading...' ] ) ;
2704
- Scheduler . unstable_advanceTime ( 2000 ) ;
2705
- await advanceTimers ( 2000 ) ;
2706
- expect ( Scheduler ) . toHaveYielded ( [ 'Promise resolved [A]' ] ) ;
2707
- expect ( Scheduler ) . toFlushAndYield ( [ 'A' ] ) ;
2708
- expect ( ReactNoop . getChildren ( ) ) . toEqual ( [ span ( 'A' ) ] ) ;
2709
-
2710
- // Start transition.
2711
- React . unstable_withSuspenseConfig (
2712
- ( ) => {
2713
- // When we schedule an inner transition without a suspense config
2714
- // so it should only suspend for a short time.
2715
- React . unstable_withSuspenseConfig ( ( ) =>
2716
- ReactNoop . render ( < App page = "B" /> ) ,
2717
- ) ;
2718
- } ,
2719
- { timeoutMs : 2000 } ,
2720
- ) ;
2721
-
2722
- expect ( Scheduler ) . toFlushAndYield ( [ 'Suspend! [B]' , 'Loading...' ] ) ;
2723
- // Suspended
2724
- expect ( ReactNoop . getChildren ( ) ) . toEqual ( [ span ( 'A' ) ] ) ;
2725
- Scheduler . unstable_advanceTime ( 500 ) ;
2726
- await advanceTimers ( 500 ) ;
2727
- // Committed loading state.
2728
- expect ( ReactNoop . getChildren ( ) ) . toEqual ( [
2729
- hiddenSpan ( 'A' ) ,
2730
- span ( 'Loading...' ) ,
2731
- ] ) ;
2732
-
2733
- Scheduler . unstable_advanceTime ( 2000 ) ;
2734
- await advanceTimers ( 2000 ) ;
2735
- expect ( Scheduler ) . toHaveYielded ( [ 'Promise resolved [B]' ] ) ;
2736
- expect ( Scheduler ) . toFlushAndYield ( [ 'B' ] ) ;
2737
- expect ( ReactNoop . getChildren ( ) ) . toEqual ( [ span ( 'B' ) ] ) ;
2738
-
2739
- React . unstable_withSuspenseConfig (
2740
- ( ) => {
2741
- // First we schedule an inner unrelated update.
2742
- React . unstable_withSuspenseConfig ( ( ) =>
2743
- ReactNoop . render ( < App page = "B" unrelated = { true } /> ) ,
2744
- ) ;
2745
- // Then we schedule another transition to a slow page,
2746
- // but at this scope we should suspend for longer.
2747
- Scheduler . unstable_next ( ( ) => ReactNoop . render ( < App page = "C" /> ) ) ;
2748
- } ,
2749
- { timeoutMs : 60000 } ,
2750
- ) ;
2751
- expect ( Scheduler ) . toFlushAndYield ( [ 'B' , 'Suspend! [C]' , 'Loading...' ] ) ;
2752
- expect ( ReactNoop . getChildren ( ) ) . toEqual ( [ span ( 'B' ) ] ) ;
2753
- // Event after a large amount of time, we never show a loading state.
2754
- Scheduler . unstable_advanceTime ( 60000 ) ;
2755
- await advanceTimers ( 60000 ) ;
2756
- expect ( ReactNoop . getChildren ( ) ) . toEqual ( [ span ( 'B' ) ] ) ;
2757
- } ) ;
2758
-
2759
- // @gate experimental
2760
- it ( 'withSuspenseConfig delay applies when we use an updated avoided boundary' , async ( ) => {
2664
+ it ( 'do not show placeholder when updating an avoided boundary with startTransition' , async ( ) => {
2761
2665
function App ( { page} ) {
2762
2666
return (
2763
2667
< Suspense fallback = { < Text text = "Loading..." /> } >
@@ -2780,10 +2684,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
2780
2684
expect ( ReactNoop . getChildren ( ) ) . toEqual ( [ span ( 'Hi!' ) , span ( 'A' ) ] ) ;
2781
2685
2782
2686
// Start transition.
2783
- React . unstable_withSuspenseConfig (
2784
- ( ) => ReactNoop . render ( < App page = "B" /> ) ,
2785
- { timeoutMs : 2000 } ,
2786
- ) ;
2687
+ React . unstable_startTransition ( ( ) => ReactNoop . render ( < App page = "B" /> ) ) ;
2787
2688
2788
2689
expect ( Scheduler ) . toFlushAndYield ( [ 'Hi!' , 'Suspend! [B]' , 'Loading B...' ] ) ;
2789
2690
@@ -2806,7 +2707,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
2806
2707
} ) ;
2807
2708
2808
2709
// @gate experimental
2809
- it ( 'withSuspenseConfig delay applies when we use a newly created avoided boundary' , async ( ) => {
2710
+ it ( 'do not show placeholder when mounting an avoided boundary with startTransition ' , async ( ) => {
2810
2711
function App ( { page} ) {
2811
2712
return (
2812
2713
< Suspense fallback = { < Text text = "Loading..." /> } >
@@ -2830,10 +2731,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
2830
2731
expect ( ReactNoop . getChildren ( ) ) . toEqual ( [ span ( 'Hi!' ) , span ( 'A' ) ] ) ;
2831
2732
2832
2733
// Start transition.
2833
- React . unstable_withSuspenseConfig (
2834
- ( ) => ReactNoop . render ( < App page = "B" /> ) ,
2835
- { timeoutMs : 2000 } ,
2836
- ) ;
2734
+ React . unstable_startTransition ( ( ) => ReactNoop . render ( < App page = "B" /> ) ) ;
2837
2735
2838
2736
expect ( Scheduler ) . toFlushAndYield ( [ 'Hi!' , 'Suspend! [B]' , 'Loading B...' ] ) ;
2839
2737
@@ -2992,12 +2890,9 @@ describe('ReactSuspenseWithNoopRenderer', () => {
2992
2890
expect ( ReactNoop ) . toMatchRenderedOutput ( < div hidden = { true } /> ) ;
2993
2891
2994
2892
// Start transition.
2995
- React . unstable_withSuspenseConfig (
2996
- ( ) => {
2997
- ReactNoop . render ( < App showContent = { true } /> ) ;
2998
- } ,
2999
- { timeoutMs : 2500 } ,
3000
- ) ;
2893
+ React . unstable_startTransition ( ( ) => {
2894
+ ReactNoop . render ( < App showContent = { true } /> ) ;
2895
+ } ) ;
3001
2896
3002
2897
expect ( Scheduler ) . toFlushAndYield ( [ 'Suspend! [A]' , 'Loading...' ] ) ;
3003
2898
Scheduler . unstable_advanceTime ( 2000 ) ;
@@ -3049,12 +2944,9 @@ describe('ReactSuspenseWithNoopRenderer', () => {
3049
2944
expect ( Scheduler ) . toFlushAndYieldThrough ( [ 'Suspend! [A]' ] ) ;
3050
2945
3051
2946
// Start transition.
3052
- React . unstable_withSuspenseConfig (
3053
- ( ) => {
3054
- ReactNoop . render ( < App showContent = { true } /> ) ;
3055
- } ,
3056
- { timeoutMs : 5000 } ,
3057
- ) ;
2947
+ React . unstable_startTransition ( ( ) => {
2948
+ ReactNoop . render ( < App showContent = { true } /> ) ;
2949
+ } ) ;
3058
2950
3059
2951
expect ( Scheduler ) . toFlushAndYield ( [ 'Suspend! [A]' , 'Loading...' ] ) ;
3060
2952
Scheduler . unstable_advanceTime ( 2000 ) ;
0 commit comments