@@ -1306,44 +1306,25 @@ describe('ReactDOMServerHooks', () => {
1306
1306
// State update should trigger the ID to update, which changes the props
1307
1307
// of ChildWithID. This should cause ChildWithID to hydrate before Children
1308
1308
1309
- gate ( flags => {
1310
- if ( __DEV__ ) {
1311
- expect ( Scheduler ) . toFlushAndYieldThrough ( [
1312
- 'Child with ID' ,
1313
- // Fallbacks are immdiately committed in TestUtils version
1314
- // of act
1315
- // 'Child with ID',
1316
- // 'Child with ID',
1317
- 'Child One' ,
1318
- 'Child Two' ,
1319
- ] ) ;
1320
- } else if ( flags . new ) {
1321
- // Upgrading a dehyrdating boundary works a little differently in
1322
- // the new reconciler. After the update on the boundary is
1323
- // scheduled, it waits until the end of the current time slice
1324
- // before restarting at the higher priority.
1325
- expect ( Scheduler ) . toFlushAndYieldThrough ( [
1326
- 'Child with ID' ,
1327
- 'Child with ID' ,
1328
- 'Child with ID' ,
1329
- 'Child with ID' ,
1330
- 'Child One' ,
1331
- 'Child Two' ,
1332
- ] ) ;
1333
- } else {
1334
- // Whereas the old reconciler relies on a Scheduler hack to
1335
- // interrupt the current task. It's not clear if this is any
1336
- // better or worse, though. Regardless it's not a big deal since
1337
- // the time slices aren't that big.
1338
- expect ( Scheduler ) . toFlushAndYieldThrough ( [
1339
- 'Child with ID' ,
1340
- 'Child with ID' ,
1341
- 'Child with ID' ,
1342
- 'Child One' ,
1343
- 'Child Two' ,
1344
- ] ) ;
1345
- }
1346
- } ) ;
1309
+ expect ( Scheduler ) . toFlushAndYieldThrough (
1310
+ __DEV__
1311
+ ? [
1312
+ 'Child with ID' ,
1313
+ // Fallbacks are immediately committed in TestUtils version
1314
+ // of act
1315
+ // 'Child with ID',
1316
+ // 'Child with ID',
1317
+ 'Child One' ,
1318
+ 'Child Two' ,
1319
+ ]
1320
+ : [
1321
+ 'Child with ID' ,
1322
+ 'Child with ID' ,
1323
+ 'Child with ID' ,
1324
+ 'Child One' ,
1325
+ 'Child Two' ,
1326
+ ] ,
1327
+ ) ;
1347
1328
1348
1329
expect ( child1Ref . current ) . toBe ( null ) ;
1349
1330
expect ( childWithIDRef . current ) . toEqual (
@@ -1691,15 +1672,24 @@ describe('ReactDOMServerHooks', () => {
1691
1672
1692
1673
ReactDOM . createRoot ( container , { hydrate : true } ) . render ( < App /> ) ;
1693
1674
1694
- expect ( ( ) =>
1695
- expect ( ( ) => Scheduler . unstable_flushAll ( ) ) . toThrow (
1675
+ if ( gate ( flags => flags . new ) ) {
1676
+ expect ( ( ) => Scheduler . unstable_flushAll ( ) ) . toErrorDev ( [
1696
1677
'The object passed back from useOpaqueIdentifier is meant to be passed through to attributes only. ' +
1697
1678
'Do not read the value directly.' ,
1698
- ) ,
1699
- ) . toErrorDev ( [
1700
- 'The object passed back from useOpaqueIdentifier is meant to be passed through to attributes only. ' +
1701
- 'Do not read the value directly.' ,
1702
- ] ) ;
1679
+ ] ) ;
1680
+ } else {
1681
+ // In the old reconciler, the error isn't surfaced to the user. That
1682
+ // part isn't important, as long as It warns.
1683
+ expect ( ( ) =>
1684
+ expect ( ( ) => Scheduler . unstable_flushAll ( ) ) . toThrow (
1685
+ 'The object passed back from useOpaqueIdentifier is meant to be passed through to attributes only. ' +
1686
+ 'Do not read the value directly.' ,
1687
+ ) ,
1688
+ ) . toErrorDev ( [
1689
+ 'The object passed back from useOpaqueIdentifier is meant to be passed through to attributes only. ' +
1690
+ 'Do not read the value directly.' ,
1691
+ ] ) ;
1692
+ }
1703
1693
} ) ;
1704
1694
1705
1695
it ( 'useOpaqueIdentifier throws if you try to add the result as a number in a child component wrapped in a Suspense' , async ( ) => {
@@ -1724,15 +1714,24 @@ describe('ReactDOMServerHooks', () => {
1724
1714
1725
1715
ReactDOM . createRoot ( container , { hydrate : true } ) . render ( < App /> ) ;
1726
1716
1727
- expect ( ( ) =>
1728
- expect ( ( ) => Scheduler . unstable_flushAll ( ) ) . toThrow (
1717
+ if ( gate ( flags => flags . new ) ) {
1718
+ expect ( ( ) => Scheduler . unstable_flushAll ( ) ) . toErrorDev ( [
1729
1719
'The object passed back from useOpaqueIdentifier is meant to be passed through to attributes only. ' +
1730
1720
'Do not read the value directly.' ,
1731
- ) ,
1732
- ) . toErrorDev ( [
1733
- 'The object passed back from useOpaqueIdentifier is meant to be passed through to attributes only. ' +
1734
- 'Do not read the value directly.' ,
1735
- ] ) ;
1721
+ ] ) ;
1722
+ } else {
1723
+ // In the old reconciler, the error isn't surfaced to the user. That
1724
+ // part isn't important, as long as It warns.
1725
+ expect ( ( ) =>
1726
+ expect ( ( ) => Scheduler . unstable_flushAll ( ) ) . toThrow (
1727
+ 'The object passed back from useOpaqueIdentifier is meant to be passed through to attributes only. ' +
1728
+ 'Do not read the value directly.' ,
1729
+ ) ,
1730
+ ) . toErrorDev ( [
1731
+ 'The object passed back from useOpaqueIdentifier is meant to be passed through to attributes only. ' +
1732
+ 'Do not read the value directly.' ,
1733
+ ] ) ;
1734
+ }
1736
1735
} ) ;
1737
1736
1738
1737
it ( 'useOpaqueIdentifier with two opaque identifiers on the same page' , ( ) => {
0 commit comments