File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed
packages/react-reconciler/src/__tests__ Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -1472,4 +1472,32 @@ describe('ReactUse', () => {
14721472 assertLog ( [ 'Hi' ] ) ;
14731473 expect ( root ) . toMatchRenderedOutput ( 'Hi' ) ;
14741474 } ) ;
1475+
1476+ test ( 'basic use(promise) with forwardRefs' , async ( ) => {
1477+ const promiseA = Promise . resolve ( 'A' ) ;
1478+ const promiseB = Promise . resolve ( 'B' ) ;
1479+ const promiseC = Promise . resolve ( 'C' ) ;
1480+
1481+ const Async = React . forwardRef ( ( props , ref ) => {
1482+ const text = use ( promiseA ) + use ( promiseB ) + use ( promiseC ) ;
1483+ return < Text text = { text } /> ;
1484+ } ) ;
1485+
1486+ function App ( ) {
1487+ return (
1488+ < Suspense fallback = { < Text text = "Loading..." /> } >
1489+ < Async />
1490+ </ Suspense >
1491+ ) ;
1492+ }
1493+
1494+ const root = ReactNoop . createRoot ( ) ;
1495+ await act ( ( ) => {
1496+ startTransition ( ( ) => {
1497+ root . render ( < App /> ) ;
1498+ } ) ;
1499+ } ) ;
1500+ assertLog ( [ 'ABC' ] ) ;
1501+ expect ( root ) . toMatchRenderedOutput ( 'ABC' ) ;
1502+ } ) ;
14751503} ) ;
You can’t perform that action at this time.
0 commit comments