@@ -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
@@ -1786,6 +1787,7 @@ describe('ReactIncrementalErrorHandling', () => {
1786
1787
} ) ;
1787
1788
}
1788
1789
1790
+ // @gate experimental
1789
1791
it ( 'uncaught errors should be discarded if the render is aborted' , async ( ) => {
1790
1792
const root = ReactNoop . createRoot ( ) ;
1791
1793
@@ -1795,22 +1797,24 @@ describe('ReactIncrementalErrorHandling', () => {
1795
1797
}
1796
1798
1797
1799
await ReactNoop . act ( async ( ) => {
1798
- ReactNoop . discreteUpdates ( ( ) => {
1799
- root . render ( < Oops /> ) ;
1800
- } ) ;
1800
+ root . render ( < Oops /> ) ;
1801
+
1801
1802
// Render past the component that throws, then yield.
1802
1803
expect ( Scheduler ) . toFlushAndYieldThrough ( [ 'Oops' ] ) ;
1803
1804
expect ( root ) . toMatchRenderedOutput ( null ) ;
1804
1805
// Interleaved update. When the root completes, instead of throwing the
1805
1806
// error, it should try rendering again. This update will cause it to
1806
1807
// recover gracefully.
1807
- root . render ( 'Everything is fine.' ) ;
1808
+ React . unstable_startTransition ( ( ) => {
1809
+ root . render ( 'Everything is fine.' ) ;
1810
+ } ) ;
1808
1811
} ) ;
1809
1812
1810
1813
// Should finish without throwing.
1811
1814
expect ( root ) . toMatchRenderedOutput ( 'Everything is fine.' ) ;
1812
1815
} ) ;
1813
1816
1817
+ // @gate experimental
1814
1818
it ( 'uncaught errors are discarded if the render is aborted, case 2' , async ( ) => {
1815
1819
const { useState} = React ;
1816
1820
const root = ReactNoop . createRoot ( ) ;
@@ -1835,21 +1839,20 @@ describe('ReactIncrementalErrorHandling', () => {
1835
1839
} ) ;
1836
1840
1837
1841
await ReactNoop . act ( async ( ) => {
1838
- // Schedule a high pri and a low pri update on the root.
1839
- ReactNoop . discreteUpdates ( ( ) => {
1840
- root . render ( < Oops /> ) ;
1842
+ // Schedule a default pri and a low pri update on the root.
1843
+ root . render ( < Oops /> ) ;
1844
+ React . unstable_startTransition ( ( ) => {
1845
+ root . render ( < AllGood /> ) ;
1841
1846
} ) ;
1842
- root . render ( < AllGood /> ) ;
1843
- // Render through just the high pri update. The low pri update remains on
1847
+
1848
+ // Render through just the default pri update. The low pri update remains on
1844
1849
// the queue.
1845
1850
expect ( Scheduler ) . toFlushAndYieldThrough ( [ 'Everything is fine.' ] ) ;
1846
1851
1847
- // Schedule a high pri update on a child that triggers an error.
1852
+ // Schedule a default pri update on a child that triggers an error.
1848
1853
// The root should capture this error. But since there's still a pending
1849
1854
// update on the root, the error should be suppressed.
1850
- ReactNoop . discreteUpdates ( ( ) => {
1851
- setShouldThrow ( true ) ;
1852
- } ) ;
1855
+ setShouldThrow ( true ) ;
1853
1856
} ) ;
1854
1857
// Should render the final state without throwing the error.
1855
1858
expect ( Scheduler ) . toHaveYielded ( [ 'Everything is fine.' ] ) ;
0 commit comments