@@ -123,28 +123,24 @@ describe('reactiverefs', () => {
123123 let testRefsComponent ;
124124 expect ( ( ) => {
125125 testRefsComponent = ReactDOM . render ( < TestRefsComponent /> , container ) ;
126- } ) . toErrorDev (
127- ReactFeatureFlags . warnAboutStringRefs
128- ? [
129- 'Warning: Component "div" contains the string ref "resetDiv". ' +
130- 'Support for string refs will be removed in a future major release. ' +
131- 'We recommend using useRef() or createRef() instead. ' +
132- 'Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref\n' +
133- ' in div (at **)\n' +
134- ' in TestRefsComponent (at **)' ,
135- 'Warning: Component "span" contains the string ref "clickLog0". ' +
136- 'Support for string refs will be removed in a future major release. ' +
137- 'We recommend using useRef() or createRef() instead. ' +
138- 'Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref\n' +
139- ' in span (at **)\n' +
140- ' in ClickCounter (at **)\n' +
141- ' in div (at **)\n' +
142- ' in GeneralContainerComponent (at **)\n' +
143- ' in div (at **)\n' +
144- ' in TestRefsComponent (at **)' ,
145- ]
146- : [ ] ,
147- ) ;
126+ } ) . toErrorDev ( [
127+ 'Warning: Component "div" contains the string ref "resetDiv". ' +
128+ 'Support for string refs will be removed in a future major release. ' +
129+ 'We recommend using useRef() or createRef() instead. ' +
130+ 'Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref\n' +
131+ ' in div (at **)\n' +
132+ ' in TestRefsComponent (at **)' ,
133+ 'Warning: Component "span" contains the string ref "clickLog0". ' +
134+ 'Support for string refs will be removed in a future major release. ' +
135+ 'We recommend using useRef() or createRef() instead. ' +
136+ 'Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref\n' +
137+ ' in span (at **)\n' +
138+ ' in ClickCounter (at **)\n' +
139+ ' in div (at **)\n' +
140+ ' in GeneralContainerComponent (at **)\n' +
141+ ' in div (at **)\n' +
142+ ' in TestRefsComponent (at **)' ,
143+ ] ) ;
148144
149145 expect ( testRefsComponent instanceof TestRefsComponent ) . toBe ( true ) ;
150146
@@ -349,17 +345,13 @@ describe('ref swapping', () => {
349345 let a ;
350346 expect ( ( ) => {
351347 a = ReactTestUtils . renderIntoDocument ( < A /> ) ;
352- } ) . toErrorDev (
353- ReactFeatureFlags . warnAboutStringRefs
354- ? [
355- 'Warning: Component "A" contains the string ref "1". ' +
356- 'Support for string refs will be removed in a future major release. ' +
357- 'We recommend using useRef() or createRef() instead. ' +
358- 'Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref\n' +
359- ' in A (at **)' ,
360- ]
361- : [ ] ,
362- ) ;
348+ } ) . toErrorDev ( [
349+ 'Warning: Component "A" contains the string ref "1". ' +
350+ 'Support for string refs will be removed in a future major release. ' +
351+ 'We recommend using useRef() or createRef() instead. ' +
352+ 'Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref\n' +
353+ ' in A (at **)' ,
354+ ] ) ;
363355 expect ( a . refs [ 1 ] . nodeName ) . toBe ( 'DIV' ) ;
364356 } ) ;
365357
@@ -546,18 +538,14 @@ describe('strings refs across renderers', () => {
546538 let inst ;
547539 expect ( ( ) => {
548540 inst = ReactDOM . render ( < Parent /> , div1 ) ;
549- } ) . toErrorDev (
550- ReactFeatureFlags . warnAboutStringRefs
551- ? [
552- 'Warning: Component "Indirection" contains the string ref "child1". ' +
553- 'Support for string refs will be removed in a future major release. ' +
554- 'We recommend using useRef() or createRef() instead. ' +
555- 'Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref\n' +
556- ' in Indirection (at **)\n' +
557- ' in Parent (at **)' ,
558- ]
559- : [ ] ,
560- ) ;
541+ } ) . toErrorDev ( [
542+ 'Warning: Component "Indirection" contains the string ref "child1". ' +
543+ 'Support for string refs will be removed in a future major release. ' +
544+ 'We recommend using useRef() or createRef() instead. ' +
545+ 'Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref\n' +
546+ ' in Indirection (at **)\n' +
547+ ' in Parent (at **)' ,
548+ ] ) ;
561549
562550 // Only the first ref has rendered yet.
563551 expect ( inst . refs . child1 . tagName ) . toBe ( 'DIV' ) ;
@@ -567,14 +555,12 @@ describe('strings refs across renderers', () => {
567555 // Now both refs should be rendered.
568556 ReactDOM . render ( < Parent /> , div1 ) ;
569557 } ) . toErrorDev (
570- ReactFeatureFlags . warnAboutStringRefs
571- ? [
572- 'Warning: Component "Root" contains the string ref "child2". ' +
573- 'Support for string refs will be removed in a future major release. ' +
574- 'We recommend using useRef() or createRef() instead. ' +
575- 'Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref' ,
576- ]
577- : [ ] ,
558+ [
559+ 'Warning: Component "Root" contains the string ref "child2". ' +
560+ 'Support for string refs will be removed in a future major release. ' +
561+ 'We recommend using useRef() or createRef() instead. ' +
562+ 'Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref' ,
563+ ] ,
578564 { withoutStack : true } ,
579565 ) ;
580566 expect ( inst . refs . child1 . tagName ) . toBe ( 'DIV' ) ;
0 commit comments