@@ -57,7 +57,7 @@ function initModules() {
57
57
useDebugValue = React . useDebugValue ;
58
58
useImperativeHandle = React . useImperativeHandle ;
59
59
useLayoutEffect = React . useLayoutEffect ;
60
- useOpaqueIdentifier = React . useOpaqueIdentifier ;
60
+ useOpaqueIdentifier = React . unstable_useOpaqueIdentifier ;
61
61
forwardRef = React . forwardRef ;
62
62
63
63
yieldedValues = [ ] ;
@@ -1645,99 +1645,99 @@ describe('ReactDOMServerHooks', () => {
1645
1645
'Do not read the value directly.' ,
1646
1646
] ) ;
1647
1647
} ) ;
1648
- } ) ;
1649
1648
1650
- it ( 'useOpaqueIdentifier throws if you try to add the result as a number in a child component wrapped in a Suspense' , async ( ) => {
1651
- function Child ( { appId} ) {
1652
- return < div aria-labelledby = { + appId } /> ;
1653
- }
1654
- function App ( ) {
1655
- const [ show ] = useState ( false ) ;
1656
- const id = useOpaqueIdentifier ( ) ;
1657
- return (
1658
- < React . Suspense fallback = { null } >
1659
- { show && < div id = { id } /> }
1660
- < Child appId = { id } />
1661
- </ React . Suspense >
1662
- ) ;
1663
- }
1649
+ it ( 'useOpaqueIdentifier throws if you try to add the result as a number in a child component wrapped in a Suspense' , async ( ) => {
1650
+ function Child ( { appId} ) {
1651
+ return < div aria-labelledby = { + appId } /> ;
1652
+ }
1653
+ function App ( ) {
1654
+ const [ show ] = useState ( false ) ;
1655
+ const id = useOpaqueIdentifier ( ) ;
1656
+ return (
1657
+ < React . Suspense fallback = { null } >
1658
+ { show && < div id = { id } /> }
1659
+ < Child appId = { id } />
1660
+ </ React . Suspense >
1661
+ ) ;
1662
+ }
1664
1663
1665
- const container = document . createElement ( 'div' ) ;
1666
- document . body . appendChild ( container ) ;
1664
+ const container = document . createElement ( 'div' ) ;
1665
+ document . body . appendChild ( container ) ;
1667
1666
1668
- container . innerHTML = ReactDOMServer . renderToString ( < App /> ) ;
1667
+ container . innerHTML = ReactDOMServer . renderToString ( < App /> ) ;
1669
1668
1670
- ReactDOM . createRoot ( container , { hydrate : true } ) . render ( < App /> ) ;
1669
+ ReactDOM . createRoot ( container , { hydrate : true } ) . render ( < App /> ) ;
1671
1670
1672
- expect ( ( ) =>
1673
- expect ( ( ) => Scheduler . unstable_flushAll ( ) ) . toThrow (
1671
+ expect ( ( ) =>
1672
+ expect ( ( ) => Scheduler . unstable_flushAll ( ) ) . toThrow (
1673
+ 'The object passed back from useOpaqueIdentifier is meant to be passed through to attributes only. ' +
1674
+ 'Do not read the value directly.' ,
1675
+ ) ,
1676
+ ) . toErrorDev ( [
1674
1677
'The object passed back from useOpaqueIdentifier is meant to be passed through to attributes only. ' +
1675
1678
'Do not read the value directly.' ,
1676
- ) ,
1677
- ) . toErrorDev ( [
1678
- 'The object passed back from useOpaqueIdentifier is meant to be passed through to attributes only. ' +
1679
- 'Do not read the value directly.' ,
1680
- ] ) ;
1681
- } ) ;
1679
+ ] ) ;
1680
+ } ) ;
1682
1681
1683
- it ( 'useOpaqueIdentifier with two opaque identifiers on the same page' , ( ) => {
1684
- let _setShow ;
1682
+ it ( 'useOpaqueIdentifier with two opaque identifiers on the same page' , ( ) => {
1683
+ let _setShow ;
1685
1684
1686
- function App ( ) {
1687
- const id1 = useOpaqueIdentifier ( ) ;
1688
- const id2 = useOpaqueIdentifier ( ) ;
1689
- const [ show , setShow ] = useState ( true ) ;
1690
- _setShow = setShow ;
1685
+ function App ( ) {
1686
+ const id1 = useOpaqueIdentifier ( ) ;
1687
+ const id2 = useOpaqueIdentifier ( ) ;
1688
+ const [ show , setShow ] = useState ( true ) ;
1689
+ _setShow = setShow ;
1691
1690
1692
- return (
1693
- < div >
1694
- < React . Suspense fallback = { null } >
1695
- { show ? (
1696
- < span id = { id1 } > { 'Child' } </ span >
1697
- ) : (
1698
- < span id = { id2 } > { 'Child' } </ span >
1699
- ) }
1700
- </ React . Suspense >
1701
- < span aria-labelledby = { id1 } > { 'test' } </ span >
1702
- </ div >
1703
- ) ;
1704
- }
1691
+ return (
1692
+ < div >
1693
+ < React . Suspense fallback = { null } >
1694
+ { show ? (
1695
+ < span id = { id1 } > { 'Child' } </ span >
1696
+ ) : (
1697
+ < span id = { id2 } > { 'Child' } </ span >
1698
+ ) }
1699
+ </ React . Suspense >
1700
+ < span aria-labelledby = { id1 } > { 'test' } </ span >
1701
+ </ div >
1702
+ ) ;
1703
+ }
1705
1704
1706
- const container = document . createElement ( 'div' ) ;
1707
- document . body . appendChild ( container ) ;
1705
+ const container = document . createElement ( 'div' ) ;
1706
+ document . body . appendChild ( container ) ;
1708
1707
1709
- container . innerHTML = ReactDOMServer . renderToString ( < App /> ) ;
1708
+ container . innerHTML = ReactDOMServer . renderToString ( < App /> ) ;
1710
1709
1711
- const serverID = container
1712
- . getElementsByTagName ( 'span' ) [ 0 ]
1713
- . getAttribute ( 'id' ) ;
1714
- expect ( serverID ) . not . toBeNull ( ) ;
1715
- expect (
1716
- container
1717
- . getElementsByTagName ( 'span' ) [ 1 ]
1718
- . getAttribute ( 'aria-labelledby' ) ,
1719
- ) . toEqual ( serverID ) ;
1710
+ const serverID = container
1711
+ . getElementsByTagName ( 'span' ) [ 0 ]
1712
+ . getAttribute ( 'id' ) ;
1713
+ expect ( serverID ) . not . toBeNull ( ) ;
1714
+ expect (
1715
+ container
1716
+ . getElementsByTagName ( 'span' ) [ 1 ]
1717
+ . getAttribute ( 'aria-labelledby' ) ,
1718
+ ) . toEqual ( serverID ) ;
1720
1719
1721
- ReactDOM . createRoot ( container , { hydrate : true } ) . render ( < App /> ) ;
1722
- jest . runAllTimers ( ) ;
1723
- expect ( Scheduler ) . toHaveYielded ( [ ] ) ;
1724
- expect ( Scheduler ) . toFlushAndYield ( [ ] ) ;
1720
+ ReactDOM . createRoot ( container , { hydrate : true } ) . render ( < App /> ) ;
1721
+ jest . runAllTimers ( ) ;
1722
+ expect ( Scheduler ) . toHaveYielded ( [ ] ) ;
1723
+ expect ( Scheduler ) . toFlushAndYield ( [ ] ) ;
1725
1724
1726
- ReactTestUtils . act ( ( ) => {
1727
- _setShow ( false ) ;
1728
- } ) ;
1725
+ ReactTestUtils . act ( ( ) => {
1726
+ _setShow ( false ) ;
1727
+ } ) ;
1729
1728
1730
- expect (
1731
- container
1732
- . getElementsByTagName ( 'span' ) [ 1 ]
1733
- . getAttribute ( 'aria-labelledby' ) ,
1734
- ) . toEqual ( serverID ) ;
1735
- expect (
1736
- container . getElementsByTagName ( 'span' ) [ 0 ] . getAttribute ( 'id' ) ,
1737
- ) . not . toEqual ( serverID ) ;
1738
- expect (
1739
- container . getElementsByTagName ( 'span' ) [ 0 ] . getAttribute ( 'id' ) ,
1740
- ) . not . toBeNull ( ) ;
1729
+ expect (
1730
+ container
1731
+ . getElementsByTagName ( 'span' ) [ 1 ]
1732
+ . getAttribute ( 'aria-labelledby' ) ,
1733
+ ) . toEqual ( serverID ) ;
1734
+ expect (
1735
+ container . getElementsByTagName ( 'span' ) [ 0 ] . getAttribute ( 'id' ) ,
1736
+ ) . not . toEqual ( serverID ) ;
1737
+ expect (
1738
+ container . getElementsByTagName ( 'span' ) [ 0 ] . getAttribute ( 'id' ) ,
1739
+ ) . not . toBeNull ( ) ;
1740
+ } ) ;
1741
1741
} ) ;
1742
1742
}
1743
1743
} ) ;
0 commit comments