@@ -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
@@ -2314,11 +2304,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
2314
2304
expect ( ReactNoop . getChildren ( ) ) . toEqual ( [ span ( 'Loading A...' ) ] ) ;
2315
2305
} ) ;
2316
2306
2317
- describe ( 'delays transitions when there a suspense config is supplied' , ( ) => {
2318
- const SUSPENSE_CONFIG = {
2319
- timeoutMs : 2000 ,
2320
- } ;
2321
-
2307
+ describe ( 'startTransition' , ( ) => {
2322
2308
// @gate experimental
2323
2309
it ( 'top level render' , async ( ) => {
2324
2310
function App ( { page} ) {
@@ -2330,10 +2316,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
2330
2316
}
2331
2317
2332
2318
// Initial render.
2333
- React . unstable_withSuspenseConfig (
2334
- ( ) => ReactNoop . render ( < App page = "A" /> ) ,
2335
- SUSPENSE_CONFIG ,
2336
- ) ;
2319
+ React . unstable_startTransition ( ( ) => ReactNoop . render ( < App page = "A" /> ) ) ;
2337
2320
2338
2321
expect ( Scheduler ) . toFlushAndYield ( [ 'Suspend! [A]' , 'Loading...' ] ) ;
2339
2322
// Only a short time is needed to unsuspend the initial loading state.
@@ -2349,10 +2332,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
2349
2332
expect ( ReactNoop . getChildren ( ) ) . toEqual ( [ span ( 'A' ) ] ) ;
2350
2333
2351
2334
// Start transition.
2352
- React . unstable_withSuspenseConfig (
2353
- ( ) => ReactNoop . render ( < App page = "B" /> ) ,
2354
- SUSPENSE_CONFIG ,
2355
- ) ;
2335
+ React . unstable_startTransition ( ( ) => ReactNoop . render ( < App page = "B" /> ) ) ;
2356
2336
2357
2337
expect ( Scheduler ) . toFlushAndYield ( [ 'Suspend! [B]' , 'Loading...' ] ) ;
2358
2338
Scheduler . unstable_advanceTime ( 100000 ) ;
@@ -2389,10 +2369,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
2389
2369
2390
2370
// Initial render.
2391
2371
await ReactNoop . act ( async ( ) => {
2392
- React . unstable_withSuspenseConfig (
2393
- ( ) => transitionToPage ( 'A' ) ,
2394
- SUSPENSE_CONFIG ,
2395
- ) ;
2372
+ React . unstable_startTransition ( ( ) => transitionToPage ( 'A' ) ) ;
2396
2373
2397
2374
expect ( Scheduler ) . toFlushAndYield ( [ 'Suspend! [A]' , 'Loading...' ] ) ;
2398
2375
// Only a short time is needed to unsuspend the initial loading state.
@@ -2409,10 +2386,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
2409
2386
2410
2387
// Start transition.
2411
2388
await ReactNoop . act ( async ( ) => {
2412
- React . unstable_withSuspenseConfig (
2413
- ( ) => transitionToPage ( 'B' ) ,
2414
- SUSPENSE_CONFIG ,
2415
- ) ;
2389
+ React . unstable_startTransition ( ( ) => transitionToPage ( 'B' ) ) ;
2416
2390
2417
2391
expect ( Scheduler ) . toFlushAndYield ( [ 'Suspend! [B]' , 'Loading...' ] ) ;
2418
2392
Scheduler . unstable_advanceTime ( 100000 ) ;
@@ -2452,10 +2426,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
2452
2426
2453
2427
// Initial render.
2454
2428
await ReactNoop . act ( async ( ) => {
2455
- React . unstable_withSuspenseConfig (
2456
- ( ) => transitionToPage ( 'A' ) ,
2457
- SUSPENSE_CONFIG ,
2458
- ) ;
2429
+ React . unstable_startTransition ( ( ) => transitionToPage ( 'A' ) ) ;
2459
2430
2460
2431
expect ( Scheduler ) . toFlushAndYield ( [ 'Suspend! [A]' , 'Loading...' ] ) ;
2461
2432
// Only a short time is needed to unsuspend the initial loading state.
@@ -2472,10 +2443,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
2472
2443
2473
2444
// Start transition.
2474
2445
await ReactNoop . act ( async ( ) => {
2475
- React . unstable_withSuspenseConfig (
2476
- ( ) => transitionToPage ( 'B' ) ,
2477
- SUSPENSE_CONFIG ,
2478
- ) ;
2446
+ React . unstable_startTransition ( ( ) => transitionToPage ( 'B' ) ) ;
2479
2447
2480
2448
expect ( Scheduler ) . toFlushAndYield ( [ 'Suspend! [B]' , 'Loading...' ] ) ;
2481
2449
Scheduler . unstable_advanceTime ( 100000 ) ;
@@ -2689,75 +2657,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
2689
2657
} ) ;
2690
2658
2691
2659
// @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 ( ) => {
2660
+ it ( 'do not show placeholder when updating an avoided boundary with startTransition' , async ( ) => {
2761
2661
function App ( { page} ) {
2762
2662
return (
2763
2663
< Suspense fallback = { < Text text = "Loading..." /> } >
@@ -2780,10 +2680,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
2780
2680
expect ( ReactNoop . getChildren ( ) ) . toEqual ( [ span ( 'Hi!' ) , span ( 'A' ) ] ) ;
2781
2681
2782
2682
// Start transition.
2783
- React . unstable_withSuspenseConfig (
2784
- ( ) => ReactNoop . render ( < App page = "B" /> ) ,
2785
- { timeoutMs : 2000 } ,
2786
- ) ;
2683
+ React . unstable_startTransition ( ( ) => ReactNoop . render ( < App page = "B" /> ) ) ;
2787
2684
2788
2685
expect ( Scheduler ) . toFlushAndYield ( [ 'Hi!' , 'Suspend! [B]' , 'Loading B...' ] ) ;
2789
2686
@@ -2806,7 +2703,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
2806
2703
} ) ;
2807
2704
2808
2705
// @gate experimental
2809
- it ( 'withSuspenseConfig delay applies when we use a newly created avoided boundary' , async ( ) => {
2706
+ it ( 'do not show placeholder when mounting an avoided boundary with startTransition ' , async ( ) => {
2810
2707
function App ( { page} ) {
2811
2708
return (
2812
2709
< Suspense fallback = { < Text text = "Loading..." /> } >
@@ -2830,10 +2727,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
2830
2727
expect ( ReactNoop . getChildren ( ) ) . toEqual ( [ span ( 'Hi!' ) , span ( 'A' ) ] ) ;
2831
2728
2832
2729
// Start transition.
2833
- React . unstable_withSuspenseConfig (
2834
- ( ) => ReactNoop . render ( < App page = "B" /> ) ,
2835
- { timeoutMs : 2000 } ,
2836
- ) ;
2730
+ React . unstable_startTransition ( ( ) => ReactNoop . render ( < App page = "B" /> ) ) ;
2837
2731
2838
2732
expect ( Scheduler ) . toFlushAndYield ( [ 'Hi!' , 'Suspend! [B]' , 'Loading B...' ] ) ;
2839
2733
@@ -2992,12 +2886,9 @@ describe('ReactSuspenseWithNoopRenderer', () => {
2992
2886
expect ( ReactNoop ) . toMatchRenderedOutput ( < div hidden = { true } /> ) ;
2993
2887
2994
2888
// Start transition.
2995
- React . unstable_withSuspenseConfig (
2996
- ( ) => {
2997
- ReactNoop . render ( < App showContent = { true } /> ) ;
2998
- } ,
2999
- { timeoutMs : 2500 } ,
3000
- ) ;
2889
+ React . unstable_startTransition ( ( ) => {
2890
+ ReactNoop . render ( < App showContent = { true } /> ) ;
2891
+ } ) ;
3001
2892
3002
2893
expect ( Scheduler ) . toFlushAndYield ( [ 'Suspend! [A]' , 'Loading...' ] ) ;
3003
2894
Scheduler . unstable_advanceTime ( 2000 ) ;
@@ -3049,12 +2940,9 @@ describe('ReactSuspenseWithNoopRenderer', () => {
3049
2940
expect ( Scheduler ) . toFlushAndYieldThrough ( [ 'Suspend! [A]' ] ) ;
3050
2941
3051
2942
// Start transition.
3052
- React . unstable_withSuspenseConfig (
3053
- ( ) => {
3054
- ReactNoop . render ( < App showContent = { true } /> ) ;
3055
- } ,
3056
- { timeoutMs : 5000 } ,
3057
- ) ;
2943
+ React . unstable_startTransition ( ( ) => {
2944
+ ReactNoop . render ( < App showContent = { true } /> ) ;
2945
+ } ) ;
3058
2946
3059
2947
expect ( Scheduler ) . toFlushAndYield ( [ 'Suspend! [A]' , 'Loading...' ] ) ;
3060
2948
Scheduler . unstable_advanceTime ( 2000 ) ;
0 commit comments