Skip to content

Commit

Permalink
Add test for forwardRefs second arg with use
Browse files Browse the repository at this point in the history
  • Loading branch information
hansottowirtz committed Mar 29, 2023
1 parent 10e2b33 commit 2ad09a4
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion packages/react-reconciler/src/__tests__/ReactUse-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1479,14 +1479,20 @@ describe('ReactUse', () => {
const promiseC = Promise.resolve('C');

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

let _ref;
function App() {
const ref = (arg) => {
_ref = arg
};

return (
<Suspense fallback={<Text text="Loading..." />}>
<Async />
<Async ref={ref} />
</Suspense>
);
}
Expand All @@ -1499,5 +1505,6 @@ describe('ReactUse', () => {
});
assertLog(['ABC']);
expect(root).toMatchRenderedOutput('ABC');
expect(_ref).toBeDefined();
});
});

0 comments on commit 2ad09a4

Please sign in to comment.