@@ -232,7 +232,8 @@ describe('ReactIncrementalErrorHandling', () => {
232
232
expect ( ReactNoop . getChildren ( ) ) . toEqual ( [ span ( 'Caught an error: oops!' ) ] ) ;
233
233
} ) ;
234
234
235
- it ( "retries at a lower priority if there's additional pending work" , ( ) => {
235
+ // @gate experimental
236
+ it ( "retries at a lower priority if there's additional pending work" , async ( ) => {
236
237
function App ( props ) {
237
238
if ( props . isBroken ) {
238
239
Scheduler . unstable_yieldValue ( 'error' ) ;
@@ -252,14 +253,14 @@ describe('ReactIncrementalErrorHandling', () => {
252
253
} ) ;
253
254
}
254
255
255
- ReactNoop . discreteUpdates ( ( ) => {
256
- ReactNoop . render ( < App isBroken = { true } /> , onCommit ) ;
257
- } ) ;
256
+ ReactNoop . render ( < App isBroken = { true } /> , onCommit ) ;
258
257
expect ( Scheduler ) . toFlushAndYieldThrough ( [ 'error' ] ) ;
259
258
interrupt ( ) ;
260
259
261
- // This update is in a separate batch
262
- ReactNoop . render ( < App isBroken = { false } /> , onCommit ) ;
260
+ React . unstable_startTransition ( ( ) => {
261
+ // This update is in a separate batch
262
+ ReactNoop . render ( < App isBroken = { false } /> , onCommit ) ;
263
+ } ) ;
263
264
264
265
expect ( Scheduler ) . toFlushAndYieldThrough ( [
265
266
// The first render fails. But because there's a lower priority pending
@@ -311,16 +312,16 @@ describe('ReactIncrementalErrorHandling', () => {
311
312
} ) ;
312
313
}
313
314
314
- ReactNoop . discreteUpdates ( ( ) => {
315
- ReactNoop . render ( < App isBroken = { true } /> , onCommit ) ;
316
- } ) ;
315
+ ReactNoop . render ( < App isBroken = { true } /> , onCommit ) ;
317
316
expect ( Scheduler ) . toFlushAndYieldThrough ( [ 'error' ] ) ;
318
317
interrupt ( ) ;
319
318
320
319
expect ( ReactNoop ) . toMatchRenderedOutput ( null ) ;
321
320
322
- // This update is in a separate batch
323
- ReactNoop . render ( < App isBroken = { false } /> , onCommit ) ;
321
+ React . unstable_startTransition ( ( ) => {
322
+ // This update is in a separate batch
323
+ ReactNoop . render ( < App isBroken = { false } /> , onCommit ) ;
324
+ } ) ;
324
325
325
326
expect ( Scheduler ) . toFlushAndYieldThrough ( [
326
327
// The first render fails. But because there's a lower priority pending
@@ -1780,6 +1781,7 @@ describe('ReactIncrementalErrorHandling', () => {
1780
1781
} ) ;
1781
1782
}
1782
1783
1784
+ // @gate experimental
1783
1785
it ( 'uncaught errors should be discarded if the render is aborted' , async ( ) => {
1784
1786
const root = ReactNoop . createRoot ( ) ;
1785
1787
@@ -1789,22 +1791,24 @@ describe('ReactIncrementalErrorHandling', () => {
1789
1791
}
1790
1792
1791
1793
await ReactNoop . act ( async ( ) => {
1792
- ReactNoop . discreteUpdates ( ( ) => {
1793
- root . render ( < Oops /> ) ;
1794
- } ) ;
1794
+ root . render ( < Oops /> ) ;
1795
+
1795
1796
// Render past the component that throws, then yield.
1796
1797
expect ( Scheduler ) . toFlushAndYieldThrough ( [ 'Oops' ] ) ;
1797
1798
expect ( root ) . toMatchRenderedOutput ( null ) ;
1798
1799
// Interleaved update. When the root completes, instead of throwing the
1799
1800
// error, it should try rendering again. This update will cause it to
1800
1801
// recover gracefully.
1801
- root . render ( 'Everything is fine.' ) ;
1802
+ React . unstable_startTransition ( ( ) => {
1803
+ root . render ( 'Everything is fine.' ) ;
1804
+ } ) ;
1802
1805
} ) ;
1803
1806
1804
1807
// Should finish without throwing.
1805
1808
expect ( root ) . toMatchRenderedOutput ( 'Everything is fine.' ) ;
1806
1809
} ) ;
1807
1810
1811
+ // @gate experimental
1808
1812
it ( 'uncaught errors are discarded if the render is aborted, case 2' , async ( ) => {
1809
1813
const { useState} = React ;
1810
1814
const root = ReactNoop . createRoot ( ) ;
@@ -1829,21 +1833,20 @@ describe('ReactIncrementalErrorHandling', () => {
1829
1833
} ) ;
1830
1834
1831
1835
await ReactNoop . act ( async ( ) => {
1832
- // Schedule a high pri and a low pri update on the root.
1833
- ReactNoop . discreteUpdates ( ( ) => {
1834
- root . render ( < Oops /> ) ;
1836
+ // Schedule a default pri and a low pri update on the root.
1837
+ root . render ( < Oops /> ) ;
1838
+ React . unstable_startTransition ( ( ) => {
1839
+ root . render ( < AllGood /> ) ;
1835
1840
} ) ;
1836
- root . render ( < AllGood /> ) ;
1837
- // Render through just the high pri update. The low pri update remains on
1841
+
1842
+ // Render through just the default pri update. The low pri update remains on
1838
1843
// the queue.
1839
1844
expect ( Scheduler ) . toFlushAndYieldThrough ( [ 'Everything is fine.' ] ) ;
1840
1845
1841
- // Schedule a high pri update on a child that triggers an error.
1846
+ // Schedule a default pri update on a child that triggers an error.
1842
1847
// The root should capture this error. But since there's still a pending
1843
1848
// update on the root, the error should be suppressed.
1844
- ReactNoop . discreteUpdates ( ( ) => {
1845
- setShouldThrow ( true ) ;
1846
- } ) ;
1849
+ setShouldThrow ( true ) ;
1847
1850
} ) ;
1848
1851
// Should render the final state without throwing the error.
1849
1852
expect ( Scheduler ) . toHaveYielded ( [ 'Everything is fine.' ] ) ;
0 commit comments