@@ -741,12 +741,18 @@ describe('string refs', () => {
741741 expect ( ( ) => {
742742 ReactDOM . render ( < OuterComponent /> , container ) ;
743743 } ) . toErrorDev (
744- 'Warning: A string ref, "somestring", has been found within a strict mode tree. ' +
745- 'String refs are a source of potential bugs and should be avoided. ' +
746- 'We recommend using useRef() or createRef() instead. ' +
747- 'Learn more about using refs safely here: ' +
748- 'https://reactjs.org/link/strict-mode-string-ref\n' +
749- ' in OuterComponent (at **)' ,
744+ ReactFeatureFlags . warnAboutStringRefs
745+ ? 'Warning: Component "StrictMode" contains the string ref "somestring". ' +
746+ 'Support for string refs will be removed in a future major release. ' +
747+ 'We recommend using useRef() or createRef() instead. ' +
748+ 'Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref\n' +
749+ ' in OuterComponent (at **)'
750+ : 'Warning: A string ref, "somestring", has been found within a strict mode tree. ' +
751+ 'String refs are a source of potential bugs and should be avoided. ' +
752+ 'We recommend using useRef() or createRef() instead. ' +
753+ 'Learn more about using refs safely here: ' +
754+ 'https://reactjs.org/link/strict-mode-string-ref\n' +
755+ ' in OuterComponent (at **)' ,
750756 ) ;
751757
752758 // Dedup
@@ -782,13 +788,20 @@ describe('string refs', () => {
782788 expect ( ( ) => {
783789 ReactDOM . render ( < OuterComponent /> , container ) ;
784790 } ) . toErrorDev (
785- 'Warning: A string ref, "somestring", has been found within a strict mode tree. ' +
786- 'String refs are a source of potential bugs and should be avoided. ' +
787- 'We recommend using useRef() or createRef() instead. ' +
788- 'Learn more about using refs safely here: ' +
789- 'https://reactjs.org/link/strict-mode-string-ref\n' +
790- ' in InnerComponent (at **)\n' +
791- ' in OuterComponent (at **)' ,
791+ ReactFeatureFlags . warnAboutStringRefs
792+ ? 'Warning: Component "InnerComponent" contains the string ref "somestring". ' +
793+ 'Support for string refs will be removed in a future major release. ' +
794+ 'We recommend using useRef() or createRef() instead. ' +
795+ 'Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref\n' +
796+ ' in InnerComponent (at **)\n' +
797+ ' in OuterComponent (at **)'
798+ : 'Warning: A string ref, "somestring", has been found within a strict mode tree. ' +
799+ 'String refs are a source of potential bugs and should be avoided. ' +
800+ 'We recommend using useRef() or createRef() instead. ' +
801+ 'Learn more about using refs safely here: ' +
802+ 'https://reactjs.org/link/strict-mode-string-ref\n' +
803+ ' in InnerComponent (at **)\n' +
804+ ' in OuterComponent (at **)' ,
792805 ) ;
793806
794807 // Dedup
0 commit comments