Skip to content

Commit ede13bc

Browse files
committed
Add test for forwardRefs second arg with use
1 parent d561e02 commit ede13bc

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1479,14 +1479,20 @@ describe('ReactUse', () => {
14791479
const promiseC = Promise.resolve('C');
14801480

14811481
const Async = React.forwardRef((props, ref) => {
1482+
React.useImperativeHandle(ref, () => ({}));
14821483
const text = use(promiseA) + use(promiseB) + use(promiseC);
14831484
return <Text text={text} />;
14841485
});
14851486

1487+
let _ref;
14861488
function App() {
1489+
const ref = arg => {
1490+
_ref = arg;
1491+
};
1492+
14871493
return (
14881494
<Suspense fallback={<Text text="Loading..." />}>
1489-
<Async />
1495+
<Async ref={ref} />
14901496
</Suspense>
14911497
);
14921498
}
@@ -1499,5 +1505,6 @@ describe('ReactUse', () => {
14991505
});
15001506
assertLog(['ABC']);
15011507
expect(root).toMatchRenderedOutput('ABC');
1508+
expect(_ref).toBeDefined();
15021509
});
15031510
});

0 commit comments

Comments
 (0)