File tree Expand file tree Collapse file tree 1 file changed +10
-5
lines changed
packages/react-dom/src/__tests__ Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change 1010'use strict' ;
1111
1212let 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
1516class TextWithStringRef extends React . Component {
1617 render ( ) {
@@ -21,10 +22,14 @@ class TextWithStringRef extends React.Component {
2122}
2223
2324describe ( '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' +
You can’t perform that action at this time.
0 commit comments