@@ -1289,8 +1289,6 @@ describe('ReactDOMServerHooks', () => {
12891289 . getAttribute ( 'id' ) ;
12901290 expect ( serverId ) . not . toBeNull ( ) ;
12911291
1292- const childOneSpan = container . getElementsByTagName ( 'span' ) [ 0 ] ;
1293-
12941292 const root = ReactDOM . unstable_createRoot ( container , { hydrate : true } ) ;
12951293 root . render ( < App show = { false } /> ) ;
12961294 expect ( Scheduler ) . toHaveYielded ( [ ] ) ;
@@ -1306,25 +1304,15 @@ describe('ReactDOMServerHooks', () => {
13061304 // State update should trigger the ID to update, which changes the props
13071305 // of ChildWithID. This should cause ChildWithID to hydrate before Children
13081306
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+ ] ) ;
13281316
13291317 expect ( child1Ref . current ) . toBe ( null ) ;
13301318 expect ( childWithIDRef . current ) . toEqual (
@@ -1344,7 +1332,9 @@ describe('ReactDOMServerHooks', () => {
13441332 } ) ;
13451333
13461334 // Children hydrates after ChildWithID
1347- expect ( child1Ref . current ) . toBe ( childOneSpan ) ;
1335+ expect ( child1Ref . current ) . toBe (
1336+ container . getElementsByTagName ( 'span' ) [ 0 ] ,
1337+ ) ;
13481338
13491339 Scheduler . unstable_flushAll ( ) ;
13501340
@@ -1450,9 +1440,7 @@ describe('ReactDOMServerHooks', () => {
14501440 ReactDOM . unstable_createRoot ( container , { hydrate : true } ) . render (
14511441 < App /> ,
14521442 ) ;
1453- expect ( ( ) =>
1454- expect ( ( ) => Scheduler . unstable_flushAll ( ) ) . toThrow ( ) ,
1455- ) . toErrorDev ( [
1443+ expect ( ( ) => Scheduler . unstable_flushAll ( ) ) . toErrorDev ( [
14561444 'Warning: Expected server HTML to contain a matching <div> in <div>.' ,
14571445 ] ) ;
14581446 } ) ;
@@ -1538,14 +1526,12 @@ describe('ReactDOMServerHooks', () => {
15381526 ReactDOM . unstable_createRoot ( container , { hydrate : true } ) . render (
15391527 < App /> ,
15401528 ) ;
1541- expect ( ( ) =>
1542- expect ( ( ) => Scheduler . unstable_flushAll ( ) ) . toThrow ( ) ,
1543- ) . toErrorDev ( [
1529+ expect ( ( ) => Scheduler . unstable_flushAll ( ) ) . toErrorDev ( [
15441530 'Warning: Expected server HTML to contain a matching <div> in <div>.' ,
15451531 ] ) ;
15461532 } ) ;
15471533
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 ( ) => {
15491535 function Child ( { appId} ) {
15501536 return < div aria-labelledby = { appId + '' } /> ;
15511537 }
@@ -1562,12 +1548,7 @@ describe('ReactDOMServerHooks', () => {
15621548 ReactDOM . unstable_createRoot ( container , { hydrate : true } ) . render (
15631549 < App /> ,
15641550 ) ;
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 (
15711552 [
15721553 'Warning: The object passed back from useOpaqueIdentifier is meant to be passed through to attributes only. Do not read the value directly.' ,
15731554 'Warning: Did not expect server HTML to contain a <span> in <div>.' ,
@@ -1576,7 +1557,7 @@ describe('ReactDOMServerHooks', () => {
15761557 ) ;
15771558 } ) ;
15781559
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 ( ) => {
15801561 function Child ( { appId} ) {
15811562 return < div aria-labelledby = { appId + '' } /> ;
15821563 }
@@ -1593,12 +1574,7 @@ describe('ReactDOMServerHooks', () => {
15931574 ReactDOM . unstable_createRoot ( container , { hydrate : true } ) . render (
15941575 < App /> ,
15951576 ) ;
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 (
16021578 [
16031579 'Warning: The object passed back from useOpaqueIdentifier is meant to be passed through to attributes only. Do not read the value directly.' ,
16041580 'Warning: Did not expect server HTML to contain a <span> in <div>.' ,
@@ -1607,7 +1583,7 @@ describe('ReactDOMServerHooks', () => {
16071583 ) ;
16081584 } ) ;
16091585
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 ( ) => {
16111587 function Child ( { appId} ) {
16121588 return < div aria-labelledby = { appId + '' } /> ;
16131589 }
@@ -1623,12 +1599,7 @@ describe('ReactDOMServerHooks', () => {
16231599 ReactDOM . unstable_createRoot ( container , { hydrate : true } ) . render (
16241600 < App /> ,
16251601 ) ;
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 (
16321603 [
16331604 'Warning: The object passed back from useOpaqueIdentifier is meant to be passed through to attributes only. Do not read the value directly.' ,
16341605 'Warning: Did not expect server HTML to contain a <div> in <div>.' ,
@@ -1637,7 +1608,7 @@ describe('ReactDOMServerHooks', () => {
16371608 ) ;
16381609 } ) ;
16391610
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 ( ) => {
16411612 function App ( ) {
16421613 const id = useOpaqueIdentifier ( ) ;
16431614 return < div aria-labelledby = { id + '' } /> ;
@@ -1650,12 +1621,7 @@ describe('ReactDOMServerHooks', () => {
16501621 ReactDOM . unstable_createRoot ( container , { hydrate : true } ) . render (
16511622 < App /> ,
16521623 ) ;
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 (
16591625 [
16601626 'Warning: The object passed back from useOpaqueIdentifier is meant to be passed through to attributes only. Do not read the value directly.' ,
16611627 'Warning: Did not expect server HTML to contain a <div> in <div>.' ,
@@ -1664,7 +1630,7 @@ describe('ReactDOMServerHooks', () => {
16641630 ) ;
16651631 } ) ;
16661632
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 ( ) => {
16681634 function Child ( { appId} ) {
16691635 return < div aria-labelledby = { appId + '' } /> ;
16701636 }
@@ -1686,27 +1652,13 @@ describe('ReactDOMServerHooks', () => {
16861652 < App /> ,
16871653 ) ;
16881654
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+ ] ) ;
17071659 } ) ;
17081660
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 ( ) => {
17101662 function Child ( { appId} ) {
17111663 return < div aria-labelledby = { + appId } /> ;
17121664 }
@@ -1730,24 +1682,10 @@ describe('ReactDOMServerHooks', () => {
17301682 < App /> ,
17311683 ) ;
17321684
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+ ] ) ;
17511689 } ) ;
17521690
17531691 it ( 'useOpaqueIdentifier with two opaque identifiers on the same page' , ( ) => {
0 commit comments