Convert multiple-copies-of-react to createRoot (#28198)
Sebastian Silbermann committed
Feb 2, 2024 at 09:15 UTC
fada283639aeb79767abb3aefd05958452730032
1 file changed
+10
-5
packages/react-dom/src/__tests__/multiple-copies-of-react-test.js
+10
-5
@@ -10,7 +10,8 @@
10
'use strict';
11
12
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;
15
16
class TextWithStringRef extends React.Component {
17
render() {
@@ -21,10 +22,14 @@ class TextWithStringRef extends React.Component {
22
}
23
24
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(
33
'Element ref was specified as a string (foo) but no owner was set. This could happen for one of' +
34
' the following reasons:\n' +
35
'1. You may be adding a ref to a function component\n' +