@@ -1289,8 +1289,6 @@ describe('ReactDOMServerHooks', () => {
1289
1289
. getAttribute ( 'id' ) ;
1290
1290
expect ( serverId ) . not . toBeNull ( ) ;
1291
1291
1292
- const childOneSpan = container . getElementsByTagName ( 'span' ) [ 0 ] ;
1293
-
1294
1292
const root = ReactDOM . unstable_createRoot ( container , { hydrate : true } ) ;
1295
1293
root . render ( < App show = { false } /> ) ;
1296
1294
expect ( Scheduler ) . toHaveYielded ( [ ] ) ;
@@ -1306,25 +1304,15 @@ describe('ReactDOMServerHooks', () => {
1306
1304
// State update should trigger the ID to update, which changes the props
1307
1305
// of ChildWithID. This should cause ChildWithID to hydrate before Children
1308
1306
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
- ) ;
1307
+ expect ( Scheduler ) . toFlushAndYieldThrough ( [
1308
+ 'Child with ID' ,
1309
+ // Fallbacks are immediately committed in TestUtils version
1310
+ // of act
1311
+ // 'Child with ID',
1312
+ // 'Child with ID',
1313
+ 'Child One' ,
1314
+ 'Child Two' ,
1315
+ ] ) ;
1328
1316
1329
1317
expect ( child1Ref . current ) . toBe ( null ) ;
1330
1318
expect ( childWithIDRef . current ) . toEqual (
@@ -1344,7 +1332,9 @@ describe('ReactDOMServerHooks', () => {
1344
1332
} ) ;
1345
1333
1346
1334
// Children hydrates after ChildWithID
1347
- expect ( child1Ref . current ) . toBe ( childOneSpan ) ;
1335
+ expect ( child1Ref . current ) . toBe (
1336
+ container . getElementsByTagName ( 'span' ) [ 0 ] ,
1337
+ ) ;
1348
1338
1349
1339
Scheduler . unstable_flushAll ( ) ;
1350
1340
@@ -1450,9 +1440,7 @@ describe('ReactDOMServerHooks', () => {
1450
1440
ReactDOM . unstable_createRoot ( container , { hydrate : true } ) . render (
1451
1441
< App /> ,
1452
1442
) ;
1453
- expect ( ( ) =>
1454
- expect ( ( ) => Scheduler . unstable_flushAll ( ) ) . toThrow ( ) ,
1455
- ) . toErrorDev ( [
1443
+ expect ( ( ) => Scheduler . unstable_flushAll ( ) ) . toErrorDev ( [
1456
1444
'Warning: Expected server HTML to contain a matching <div> in <div>.' ,
1457
1445
] ) ;
1458
1446
} ) ;
@@ -1538,14 +1526,12 @@ describe('ReactDOMServerHooks', () => {
1538
1526
ReactDOM . unstable_createRoot ( container , { hydrate : true } ) . render (
1539
1527
< App /> ,
1540
1528
) ;
1541
- expect ( ( ) =>
1542
- expect ( ( ) => Scheduler . unstable_flushAll ( ) ) . toThrow ( ) ,
1543
- ) . toErrorDev ( [
1529
+ expect ( ( ) => Scheduler . unstable_flushAll ( ) ) . toErrorDev ( [
1544
1530
'Warning: Expected server HTML to contain a matching <div> in <div>.' ,
1545
1531
] ) ;
1546
1532
} ) ;
1547
1533
1548
- it ( 'useOpaqueIdentifier throws when there is a hydration error and we are using ID as a string' , async ( ) => {
1534
+ it ( 'useOpaqueIdentifier warns when there is a hydration error and we are using ID as a string' , async ( ) => {
1549
1535
function Child ( { appId} ) {
1550
1536
return < div aria-labelledby = { appId + '' } /> ;
1551
1537
}
@@ -1562,12 +1548,7 @@ describe('ReactDOMServerHooks', () => {
1562
1548
ReactDOM . unstable_createRoot ( container , { hydrate : true } ) . render (
1563
1549
< App /> ,
1564
1550
) ;
1565
- expect ( ( ) =>
1566
- expect ( ( ) => Scheduler . unstable_flushAll ( ) ) . toThrow (
1567
- 'The object passed back from useOpaqueIdentifier is meant to be passed through to attributes only. ' +
1568
- 'Do not read the value directly.' ,
1569
- ) ,
1570
- ) . toErrorDev (
1551
+ expect ( ( ) => Scheduler . unstable_flushAll ( ) ) . toErrorDev (
1571
1552
[
1572
1553
'Warning: The object passed back from useOpaqueIdentifier is meant to be passed through to attributes only. Do not read the value directly.' ,
1573
1554
'Warning: Did not expect server HTML to contain a <span> in <div>.' ,
@@ -1576,7 +1557,7 @@ describe('ReactDOMServerHooks', () => {
1576
1557
) ;
1577
1558
} ) ;
1578
1559
1579
- it ( 'useOpaqueIdentifier throws when there is a hydration error and we are using ID as a string' , async ( ) => {
1560
+ it ( 'useOpaqueIdentifier warns when there is a hydration error and we are using ID as a string' , async ( ) => {
1580
1561
function Child ( { appId} ) {
1581
1562
return < div aria-labelledby = { appId + '' } /> ;
1582
1563
}
@@ -1593,12 +1574,7 @@ describe('ReactDOMServerHooks', () => {
1593
1574
ReactDOM . unstable_createRoot ( container , { hydrate : true } ) . render (
1594
1575
< App /> ,
1595
1576
) ;
1596
- expect ( ( ) =>
1597
- expect ( ( ) => Scheduler . unstable_flushAll ( ) ) . toThrow (
1598
- 'The object passed back from useOpaqueIdentifier is meant to be passed through to attributes only. ' +
1599
- 'Do not read the value directly.' ,
1600
- ) ,
1601
- ) . toErrorDev (
1577
+ expect ( ( ) => Scheduler . unstable_flushAll ( ) ) . toErrorDev (
1602
1578
[
1603
1579
'Warning: The object passed back from useOpaqueIdentifier is meant to be passed through to attributes only. Do not read the value directly.' ,
1604
1580
'Warning: Did not expect server HTML to contain a <span> in <div>.' ,
@@ -1607,7 +1583,7 @@ describe('ReactDOMServerHooks', () => {
1607
1583
) ;
1608
1584
} ) ;
1609
1585
1610
- it ( 'useOpaqueIdentifier throws if you try to use the result as a string in a child component' , async ( ) => {
1586
+ it ( 'useOpaqueIdentifier warns if you try to use the result as a string in a child component' , async ( ) => {
1611
1587
function Child ( { appId} ) {
1612
1588
return < div aria-labelledby = { appId + '' } /> ;
1613
1589
}
@@ -1623,12 +1599,7 @@ describe('ReactDOMServerHooks', () => {
1623
1599
ReactDOM . unstable_createRoot ( container , { hydrate : true } ) . render (
1624
1600
< App /> ,
1625
1601
) ;
1626
- expect ( ( ) =>
1627
- expect ( ( ) => Scheduler . unstable_flushAll ( ) ) . toThrow (
1628
- 'The object passed back from useOpaqueIdentifier is meant to be passed through to attributes only. ' +
1629
- 'Do not read the value directly.' ,
1630
- ) ,
1631
- ) . toErrorDev (
1602
+ expect ( ( ) => Scheduler . unstable_flushAll ( ) ) . toErrorDev (
1632
1603
[
1633
1604
'Warning: The object passed back from useOpaqueIdentifier is meant to be passed through to attributes only. Do not read the value directly.' ,
1634
1605
'Warning: Did not expect server HTML to contain a <div> in <div>.' ,
@@ -1637,7 +1608,7 @@ describe('ReactDOMServerHooks', () => {
1637
1608
) ;
1638
1609
} ) ;
1639
1610
1640
- it ( 'useOpaqueIdentifier throws if you try to use the result as a string' , async ( ) => {
1611
+ it ( 'useOpaqueIdentifier warns if you try to use the result as a string' , async ( ) => {
1641
1612
function App ( ) {
1642
1613
const id = useOpaqueIdentifier ( ) ;
1643
1614
return < div aria-labelledby = { id + '' } /> ;
@@ -1650,12 +1621,7 @@ describe('ReactDOMServerHooks', () => {
1650
1621
ReactDOM . unstable_createRoot ( container , { hydrate : true } ) . render (
1651
1622
< App /> ,
1652
1623
) ;
1653
- expect ( ( ) =>
1654
- expect ( ( ) => Scheduler . unstable_flushAll ( ) ) . toThrow (
1655
- 'The object passed back from useOpaqueIdentifier is meant to be passed through to attributes only. ' +
1656
- 'Do not read the value directly.' ,
1657
- ) ,
1658
- ) . toErrorDev (
1624
+ expect ( ( ) => Scheduler . unstable_flushAll ( ) ) . toErrorDev (
1659
1625
[
1660
1626
'Warning: The object passed back from useOpaqueIdentifier is meant to be passed through to attributes only. Do not read the value directly.' ,
1661
1627
'Warning: Did not expect server HTML to contain a <div> in <div>.' ,
@@ -1664,7 +1630,7 @@ describe('ReactDOMServerHooks', () => {
1664
1630
) ;
1665
1631
} ) ;
1666
1632
1667
- it ( 'useOpaqueIdentifier throws if you try to use the result as a string in a child component wrapped in a Suspense' , async ( ) => {
1633
+ it ( 'useOpaqueIdentifier warns if you try to use the result as a string in a child component wrapped in a Suspense' , async ( ) => {
1668
1634
function Child ( { appId} ) {
1669
1635
return < div aria-labelledby = { appId + '' } /> ;
1670
1636
}
@@ -1686,27 +1652,13 @@ describe('ReactDOMServerHooks', () => {
1686
1652
< App /> ,
1687
1653
) ;
1688
1654
1689
- if ( gate ( flags => flags . new ) ) {
1690
- expect ( ( ) => Scheduler . unstable_flushAll ( ) ) . toErrorDev ( [
1691
- 'The object passed back from useOpaqueIdentifier is meant to be passed through to attributes only. ' +
1692
- 'Do not read the value directly.' ,
1693
- ] ) ;
1694
- } else {
1695
- // In the old reconciler, the error isn't surfaced to the user. That
1696
- // part isn't important, as long as It warns.
1697
- expect ( ( ) =>
1698
- expect ( ( ) => Scheduler . unstable_flushAll ( ) ) . toThrow (
1699
- 'The object passed back from useOpaqueIdentifier is meant to be passed through to attributes only. ' +
1700
- 'Do not read the value directly.' ,
1701
- ) ,
1702
- ) . toErrorDev ( [
1703
- 'The object passed back from useOpaqueIdentifier is meant to be passed through to attributes only. ' +
1704
- 'Do not read the value directly.' ,
1705
- ] ) ;
1706
- }
1655
+ expect ( ( ) => Scheduler . unstable_flushAll ( ) ) . toErrorDev ( [
1656
+ 'The object passed back from useOpaqueIdentifier is meant to be passed through to attributes only. ' +
1657
+ 'Do not read the value directly.' ,
1658
+ ] ) ;
1707
1659
} ) ;
1708
1660
1709
- it ( 'useOpaqueIdentifier throws if you try to add the result as a number in a child component wrapped in a Suspense' , async ( ) => {
1661
+ it ( 'useOpaqueIdentifier warns if you try to add the result as a number in a child component wrapped in a Suspense' , async ( ) => {
1710
1662
function Child ( { appId} ) {
1711
1663
return < div aria-labelledby = { + appId } /> ;
1712
1664
}
@@ -1730,24 +1682,10 @@ describe('ReactDOMServerHooks', () => {
1730
1682
< App /> ,
1731
1683
) ;
1732
1684
1733
- if ( gate ( flags => flags . new ) ) {
1734
- expect ( ( ) => Scheduler . unstable_flushAll ( ) ) . toErrorDev ( [
1735
- 'The object passed back from useOpaqueIdentifier is meant to be passed through to attributes only. ' +
1736
- 'Do not read the value directly.' ,
1737
- ] ) ;
1738
- } else {
1739
- // In the old reconciler, the error isn't surfaced to the user. That
1740
- // part isn't important, as long as It warns.
1741
- expect ( ( ) =>
1742
- expect ( ( ) => Scheduler . unstable_flushAll ( ) ) . toThrow (
1743
- 'The object passed back from useOpaqueIdentifier is meant to be passed through to attributes only. ' +
1744
- 'Do not read the value directly.' ,
1745
- ) ,
1746
- ) . toErrorDev ( [
1747
- 'The object passed back from useOpaqueIdentifier is meant to be passed through to attributes only. ' +
1748
- 'Do not read the value directly.' ,
1749
- ] ) ;
1750
- }
1685
+ expect ( ( ) => Scheduler . unstable_flushAll ( ) ) . toErrorDev ( [
1686
+ 'The object passed back from useOpaqueIdentifier is meant to be passed through to attributes only. ' +
1687
+ 'Do not read the value directly.' ,
1688
+ ] ) ;
1751
1689
} ) ;
1752
1690
1753
1691
it ( 'useOpaqueIdentifier with two opaque identifiers on the same page' , ( ) => {
0 commit comments