Skip to content

Commit d561e02

Browse files
committed
Add test for use hook with forwardRef
1 parent 9829d02 commit d561e02

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

packages/react-reconciler/src/__tests__/ReactUse-test.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff 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
});

0 commit comments

Comments
 (0)