@@ -129,22 +129,22 @@ describe('reactiverefs', () => {
129129 ) ;
130130 } ) ;
131131 } ) . toErrorDev ( [
132- 'Warning: Component "div" contains the string ref "resetDiv". ' +
133- 'Support for string refs will be removed in a future major release. ' +
134- 'We recommend using useRef() or createRef() instead. ' +
135- 'Learn more about using refs safely here: https://react.dev/link/strict-mode-string-ref\n' +
136- ' in div (at **)\n' +
137- ' in TestRefsComponent (at **)' ,
138- 'Warning: Component "span" contains the string ref "clickLog0". ' +
139- 'Support for string refs will be removed in a future major release. ' +
140- 'We recommend using useRef() or createRef() instead. ' +
141- 'Learn more about using refs safely here: https://react.dev/link/strict-mode-string-ref\n' +
142- ' in span (at **)\n' +
143- ' in ClickCounter (at **)\n' +
132+ 'Warning: Component "TestRefsComponent" contains the string ' +
133+ 'ref "resetDiv". Support for string refs will be removed in a ' +
134+ 'future major release. We recommend using useRef() or createRef() ' +
135+ 'instead. Learn more about using refs safely ' +
136+ 'here: https://react.dev/link/strict-mode-string-ref\n' +
144137 ' in div (at **)\n' +
145- ' in GeneralContainerComponent (at **)\n' +
146138 ' in div (at **)\n' +
147139 ' in TestRefsComponent (at **)' ,
140+ 'Warning: Component "ClickCounter" contains the string ' +
141+ 'ref "clickLog0". Support for string refs will be removed in a ' +
142+ 'future major release. We recommend using useRef() or createRef() ' +
143+ 'instead. Learn more about using refs safely ' +
144+ 'here: https://react.dev/link/strict-mode-string-ref\n' +
145+ ' in div (at **)\n' +
146+ ' in span (at **)\n' +
147+ ' in ClickCounter (at **)' ,
148148 ] ) ;
149149
150150 expect ( testRefsComponent instanceof TestRefsComponent ) . toBe ( true ) ;
@@ -352,29 +352,29 @@ describe('ref swapping', () => {
352352 'Support for string refs will be removed in a future major release. ' +
353353 'We recommend using useRef() or createRef() instead. ' +
354354 'Learn more about using refs safely here: https://react.dev/link/strict-mode-string-ref\n' +
355+ ' in div (at **)\n' +
355356 ' in A (at **)' ,
356357 ] ) ;
357358 expect ( a . refs [ 1 ] . nodeName ) . toBe ( 'DIV' ) ;
358359 } ) ;
359360
360- // @gate !disableStringRefs
361361 it ( 'provides an error for invalid refs' , async ( ) => {
362362 const container = document . createElement ( 'div' ) ;
363363 const root = ReactDOMClient . createRoot ( container ) ;
364364 await expect ( async ( ) => {
365365 await act ( ( ) => {
366366 root . render ( < div ref = { 10 } /> ) ;
367367 } ) ;
368- } ) . rejects . toThrow (
369- 'Element ref was specified as a string (10) but no owner was set.' ,
370- ) ;
368+ // TODO: This throws an AggregateError. Need to update test infra to
369+ // support matching against AggregateError.
370+ } ) . rejects . toThrow ( ) ;
371371 await expect ( async ( ) => {
372372 await act ( ( ) => {
373373 root . render ( < div ref = { true } /> ) ;
374374 } ) ;
375- } ) . rejects . toThrow (
376- 'Element ref was specified as a string (true) but no owner was set.' ,
377- ) ;
375+ // TODO: This throws an AggregateError. Need to update test infra to
376+ // support matching against AggregateError.
377+ } ) . rejects . toThrow ( ) ;
378378 await expect ( async ( ) => {
379379 await act ( ( ) => {
380380 root . render ( < div ref = { Symbol ( 'foo' ) } /> ) ;
@@ -520,14 +520,10 @@ describe('creating element with string ref in constructor', () => {
520520 await act ( ( ) => {
521521 root . render ( < RefTest /> ) ;
522522 } ) ;
523- } ) . rejects . toThrowError (
524- 'Element ref was specified as a string (p) but no owner was set. This could happen for one of' +
525- ' the following reasons:\n' +
526- '1. You may be adding a ref to a function component\n' +
527- "2. You may be adding a ref to a component that was not created inside a component's render method\n" +
528- '3. You have multiple copies of React loaded\n' +
529- 'See https://react.dev/link/refs-must-have-owner for more information.' ,
530- ) ;
523+ } )
524+ // TODO: This throws an AggregateError. Need to update test infra to
525+ // support matching against AggregateError.
526+ . rejects . toThrowError ( ) ;
531527 } ) ;
532528} ) ;
533529
@@ -581,10 +577,11 @@ describe('strings refs across renderers', () => {
581577 ) ;
582578 } ) ;
583579 } ) . toErrorDev ( [
584- 'Warning: Component "Indirection " contains the string ref "child1". ' +
580+ 'Warning: Component "Parent " contains the string ref "child1". ' +
585581 'Support for string refs will be removed in a future major release. ' +
586582 'We recommend using useRef() or createRef() instead. ' +
587583 'Learn more about using refs safely here: https://react.dev/link/strict-mode-string-ref\n' +
584+ ' in div (at **)\n' +
588585 ' in Indirection (at **)\n' +
589586 ' in Parent (at **)' ,
590587 ] ) ;
@@ -593,20 +590,10 @@ describe('strings refs across renderers', () => {
593590 expect ( inst . refs . child1 . tagName ) . toBe ( 'DIV' ) ;
594591 expect ( inst . refs . child1 ) . toBe ( div1 . firstChild ) ;
595592
596- await expect ( async ( ) => {
597- // Now both refs should be rendered.
598- await act ( ( ) => {
599- root . render ( < Parent /> ) ;
600- } ) ;
601- } ) . toErrorDev (
602- [
603- 'Warning: Component "Root" contains the string ref "child2". ' +
604- 'Support for string refs will be removed in a future major release. ' +
605- 'We recommend using useRef() or createRef() instead. ' +
606- 'Learn more about using refs safely here: https://react.dev/link/strict-mode-string-ref' ,
607- ] ,
608- { withoutStack : true } ,
609- ) ;
593+ // Now both refs should be rendered.
594+ await act ( ( ) => {
595+ root . render ( < Parent /> ) ;
596+ } ) ;
610597 expect ( inst . refs . child1 . tagName ) . toBe ( 'DIV' ) ;
611598 expect ( inst . refs . child1 ) . toBe ( div1 . firstChild ) ;
612599 expect ( inst . refs . child2 . tagName ) . toBe ( 'DIV' ) ;
0 commit comments