Skip to content

Commit b38724b

Browse files
author
Sebastian Silbermann
committed
Test that we don't call ref
1 parent 5b3cf78 commit b38724b

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

packages/react-dom/src/__tests__/ReactFunctionComponent-test.js

+4-7
Original file line numberDiff line numberDiff line change
@@ -239,21 +239,17 @@ describe('ReactFunctionComponent', () => {
239239
});
240240
});
241241

242-
it('should warn when given a function ref', async () => {
242+
it('should warn when given a function ref and ignore them', async () => {
243243
function Indirection(props) {
244244
return <div>{props.children}</div>;
245245
}
246246

247+
const ref = jest.fn();
247248
class ParentUsingFunctionRef extends React.Component {
248249
render() {
249250
return (
250251
<Indirection>
251-
<FunctionComponent
252-
name="A"
253-
ref={arg => {
254-
expect(arg).toBe(null);
255-
}}
256-
/>
252+
<FunctionComponent name="A" ref={ref} />
257253
</Indirection>
258254
);
259255
}
@@ -276,6 +272,7 @@ describe('ReactFunctionComponent', () => {
276272
' in Indirection (at **)\n' +
277273
' in ParentUsingFunctionRef (at **)',
278274
);
275+
expect(ref).not.toHaveBeenCalled();
279276

280277
const container = document.createElement('div');
281278
const root = ReactDOMClient.createRoot(container);

0 commit comments

Comments
 (0)