Skip to content

Commit

Permalink
Convert multiple-copies-of-react to createRoot (#28198)
Browse files Browse the repository at this point in the history
  • Loading branch information
eps1lon authored and gaearon committed Feb 3, 2024
1 parent 8e4fc87 commit f878878
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions packages/react-dom/src/__tests__/multiple-copies-of-react-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
'use strict';

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

class TextWithStringRef extends React.Component {
render() {
Expand All @@ -21,10 +22,14 @@ class TextWithStringRef extends React.Component {
}

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

0 comments on commit f878878

Please sign in to comment.