@samitouri / QOS-React / commits / 578c82d6a0

String ref warning shows name of ref (#12164)

Brian Vaughn committed Feb 6, 2018 at 09:00 UTC 578c82d6a04134fbe8499b877b030ba185a4430f
3 files changed +5 -4
packages/react-reconciler/src/ReactChildFiber.js
+2 -1
@@ -111,12 +111,13 @@ function coerceRef(
111 if (!didWarnAboutStringRefInStrictMode[componentName]) {
112 warning(
113 false,
114 - 'A string ref has been found within a strict mode tree. ' +
114 + 'A string ref, "%s", has been found within a strict mode tree. ' +
115 'String refs are a source of potential bugs and should be avoided. ' +
116 'We recommend using a ref callback instead.' +
117 '\n%s' +
118 '\n\nLearn more about using refs safely here:' +
119 '\nhttps://fb.me/react-strict-mode-string-ref',
120 + mixedRef,
121 getStackAddendumByWorkInProgressFiber(returnFiber),
122 );
123 didWarnAboutStringRefInStrictMode[componentName] = true;
packages/react-reconciler/src/__tests__/ReactIncrementalSideEffects-test.internal.js
+1 -1
@@ -1075,7 +1075,7 @@ describe('ReactIncrementalSideEffects', () => {
1075
1076 ReactNoop.render(<Foo />);
1077 expect(ReactNoop.flush).toWarnDev(
1078 - 'Warning: A string ref has been found within a strict mode tree.',
1078 + 'Warning: A string ref, "bar", has been found within a strict mode tree.',
1079 );
1080
1081 expect(fooInstance.refs.bar.test).toEqual('test');
packages/react/src/__tests__/ReactStrictMode-test.internal.js
+2 -2
@@ -776,7 +776,7 @@ describe('ReactStrictMode', () => {
776 expect(() => {
777 renderer = ReactTestRenderer.create(<OuterComponent />);
778 }).toWarnDev(
779 - 'Warning: A string ref has been found within a strict mode tree. ' +
779 + 'Warning: A string ref, "somestring", has been found within a strict mode tree. ' +
780 'String refs are a source of potential bugs and should be avoided. ' +
781 'We recommend using a ref callback instead.\n\n' +
782 ' in OuterComponent (at **)\n\n' +
@@ -817,7 +817,7 @@ describe('ReactStrictMode', () => {
817 expect(() => {
818 renderer = ReactTestRenderer.create(<OuterComponent />);
819 }).toWarnDev(
820 - 'Warning: A string ref has been found within a strict mode tree. ' +
820 + 'Warning: A string ref, "somestring", has been found within a strict mode tree. ' +
821 'String refs are a source of potential bugs and should be avoided. ' +
822 'We recommend using a ref callback instead.\n\n' +
823 ' in InnerComponent (at **)\n' +