Skip to content

Commit

Permalink
Test that we don't call ref
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastian Silbermann committed Feb 14, 2024
1 parent 5b3cf78 commit b38724b
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions packages/react-dom/src/__tests__/ReactFunctionComponent-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,21 +239,17 @@ describe('ReactFunctionComponent', () => {
});
});

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

const ref = jest.fn();
class ParentUsingFunctionRef extends React.Component {
render() {
return (
<Indirection>
<FunctionComponent
name="A"
ref={arg => {
expect(arg).toBe(null);
}}
/>
<FunctionComponent name="A" ref={ref} />
</Indirection>
);
}
Expand All @@ -276,6 +272,7 @@ describe('ReactFunctionComponent', () => {
' in Indirection (at **)\n' +
' in ParentUsingFunctionRef (at **)',
);
expect(ref).not.toHaveBeenCalled();

const container = document.createElement('div');
const root = ReactDOMClient.createRoot(container);
Expand Down

0 comments on commit b38724b

Please sign in to comment.