Skip to content

Commit fada283

Browse files
authored
Convert multiple-copies-of-react to createRoot (#28198)
1 parent 7026806 commit fada283

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

packages/react-dom/src/__tests__/multiple-copies-of-react-test.js

+10-5
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
'use strict';
1111

1212
let React = require('react');
13-
const ReactTestUtils = require('react-dom/test-utils');
13+
const ReactDOMClient = require('react-dom/client');
14+
const act = require('internal-test-utils').act;
1415

1516
class TextWithStringRef extends React.Component {
1617
render() {
@@ -21,10 +22,14 @@ class TextWithStringRef extends React.Component {
2122
}
2223

2324
describe('when different React version is used with string ref', () => {
24-
it('throws the "Refs must have owner" warning', () => {
25-
expect(() => {
26-
ReactTestUtils.renderIntoDocument(<TextWithStringRef />);
27-
}).toThrow(
25+
it('throws the "Refs must have owner" warning', async () => {
26+
const container = document.createElement('div');
27+
const root = ReactDOMClient.createRoot(container);
28+
await expect(
29+
act(() => {
30+
root.render(<TextWithStringRef />);
31+
}),
32+
).rejects.toThrow(
2833
'Element ref was specified as a string (foo) but no owner was set. This could happen for one of' +
2934
' the following reasons:\n' +
3035
'1. You may be adding a ref to a function component\n' +

0 commit comments

Comments
 (0)