@samitouri / QOS-React / commits / 964c263d8f

Downgrade deprecation warnings from errors to warnings (#9650)

* Initial regeneration of results.json **what is the change?:** We ran `yarn build` and updated the perf. stats record. **why make this change?:** Some commits have landed without updating this. By getting an initial update, I can run the build script again after my changes and see any size regressions. * Downgrade deprecation warnings from errors to warnings **what is the change?:** Swapping out `warning` module for a fork that uses `console.warn`. It looks like we were using the `warning` module for deprecation notices, *but* there is also a 'deprecated' module designed specifically for deprecation notices. However, we could not find any place that it was currently used. Since React's build process is not 100% clear to me, I assume it could still be used somewhere by something and just updated it along with other deprecation notices. We might consider a follow-up diff that does some clean up here; - remove 'deprecated' module if it's unused, OR - use 'deprecated' module for all our current deprecation warnings **why make this change?:** - We have had complaints about noisy warnings, in particular after introducing new deprecations - They potentially cause CI failures - Deprecations are not really time-sensitive, can ship without breaking your app, etc. For more context - https://github.com/facebook/react/issues/9395 **test plan:** `npm run test` and unit tests for the new modules and manual testing (WIP) **issue:** https://github.com/facebook/react/issues/9395 * Add 'lowPriorityWarning' to ReactExternals **what is the change?:** We won't bundle 'lowPriorityWarning' with the rest of React when building for Facebook. NOTE: A parallel commit will introduce an internal implementation of 'lowPriorityWarning' in Facebook's codebase, to compensate. Will post a comment with the diff number once that is up. **why make this change?:** So that the sync between github and Facebook can go more smoothly! **test plan:** We will see when I run the sync! But this is a reasonable first step imo. **issue:** https://github.com/facebook/react/issues/9398 * Make state mutations an error, not low-pri warning **what is the change?:** Even though this is a "deprecation" warning, we still want to use 'console.error' for it. **why make this change?:** - It's not likely to come up now, hopefully, because this warning has been present for some time - This will cause real issues in production if ignored **test plan:** `yarn test` - we did fix one test which failed bc of this change **issue:** https://github.com/facebook/react/issues/9398 * Fix test of assigning to this.state that was only passing in fiber **what is the change?:** updated a unit test for assigning directly to state; it once again raises an error and not a warning. **why make this change?:** So that tests pass **test plan:** REACT_DOM_JEST_USE_FIBER=1 yarn run test **issue:** * Update results.json

Flarnie Marchan committed May 23, 2017 at 09:35 UTC 964c263d8fc6e7119f5773f7fa857c9985db40cf
15 files changed +161 -108
scripts/rollup/modules.js
+1
@@ -162,6 +162,7 @@ function getExternalModules(externals, bundleType, isRenderer) {
162 case FB_PROD:
163 fbjsModules.forEach(module => externalModules.push(module));
164 externalModules.push('ReactCurrentOwner');
165 + externalModules.push('lowPriorityWarning');
166 if (isRenderer) {
167 externalModules.push('React');
168 if (externalModules.indexOf('react-dom') > -1) {
scripts/rollup/results.json
+62 -54
@@ -1,92 +1,92 @@
1 {
2 "bundleSizes": {
3 "react.development.js (UMD_DEV)": {
4 - "size": 123496,
5 - "gzip": 31034
4 + "size": 125119,
5 + "gzip": 31339
6 },
7 "react.production.min.js (UMD_PROD)": {
8 "size": 15753,
9 "gzip": 5824
10 },
11 "react-dom.development.js (UMD_DEV)": {
12 - "size": 592317,
13 - "gzip": 136560
12 + "size": 593408,
13 + "gzip": 136701
14 },
15 "react-dom.production.min.js (UMD_PROD)": {
16 - "size": 121979,
17 - "gzip": 38564
16 + "size": 122214,
17 + "gzip": 38682
18 },
19 "react-dom-server.development.js (UMD_DEV)": {
20 - "size": 498439,
21 - "gzip": 120624
20 + "size": 525896,
21 + "gzip": 126687
22 },
23 "react-dom-server.production.min.js (UMD_PROD)": {
24 - "size": 107169,
25 - "gzip": 33472
24 + "size": 111581,
25 + "gzip": 34959
26 },
27 "react-art.development.js (UMD_DEV)": {
28 - "size": 349177,
29 - "gzip": 77902
28 + "size": 349191,
29 + "gzip": 77905
30 },
31 "react-art.production.min.js (UMD_PROD)": {
32 - "size": 96267,
33 - "gzip": 29310
32 + "size": 96277,
33 + "gzip": 29313
34 },
35 "react.development.js (NODE_DEV)": {
36 - "size": 70293,
37 - "gzip": 17777
36 + "size": 71914,
37 + "gzip": 18276
38 },
39 "react.production.min.js (NODE_PROD)": {
40 "size": 9195,
41 "gzip": 3614
42 },
43 "React-dev.js (FB_DEV)": {
44 - "size": 71576,
45 - "gzip": 18181
44 + "size": 73423,
45 + "gzip": 18751
46 },
47 "React-prod.js (FB_PROD)": {
48 - "size": 36456,
49 - "gzip": 9216
48 + "size": 36836,
49 + "gzip": 9248
50 },
51 "ReactDOMStack-dev.js (FB_DEV)": {
52 - "size": 494069,
53 - "gzip": 117876
52 + "size": 496986,
53 + "gzip": 118763
54 },
55 "ReactDOMStack-prod.js (FB_PROD)": {
56 - "size": 352489,
57 - "gzip": 84575
56 + "size": 353129,
57 + "gzip": 84773
58 },
59 "react-dom.development.js (NODE_DEV)": {
60 - "size": 549893,
61 - "gzip": 126464
60 + "size": 550984,
61 + "gzip": 126642
62 },
63 "react-dom.production.min.js (NODE_PROD)": {
64 - "size": 118192,
65 - "gzip": 37224
64 + "size": 118427,
65 + "gzip": 37300
66 },
67 "ReactDOMFiber-dev.js (FB_DEV)": {
68 - "size": 550815,
69 - "gzip": 126958
68 + "size": 551962,
69 + "gzip": 127141
70 },
71 "ReactDOMFiber-prod.js (FB_PROD)": {
72 - "size": 410570,
73 - "gzip": 94005
72 + "size": 411657,
73 + "gzip": 94084
74 },
75 "react-dom-server.development.js (NODE_DEV)": {
76 - "size": 447050,
77 - "gzip": 108025
76 + "size": 474459,
77 + "gzip": 114087
78 },
79 "react-dom-server.production.min.js (NODE_PROD)": {
80 - "size": 101542,
81 - "gzip": 31424
80 + "size": 105956,
81 + "gzip": 32782
82 },
83 "ReactDOMServerStack-dev.js (FB_DEV)": {
84 - "size": 445736,
85 - "gzip": 107878
84 + "size": 455985,
85 + "gzip": 109831
86 },
87 "ReactDOMServerStack-prod.js (FB_PROD)": {
88 - "size": 333450,
89 - "gzip": 80260
88 + "size": 334090,
89 + "gzip": 80459
90 },
91 "ReactARTStack-dev.js (FB_DEV)": {
92 "size": 143166,
@@ -97,20 +97,20 @@
97 "gzip": 23039
98 },
99 "react-art.development.js (NODE_DEV)": {
100 - "size": 270501,
101 - "gzip": 57767
100 + "size": 270515,
101 + "gzip": 57772
102 },
103 "react-art.production.min.js (NODE_PROD)": {
104 - "size": 57652,
105 - "gzip": 17386
104 + "size": 57662,
105 + "gzip": 17391
106 },
107 "ReactARTFiber-dev.js (FB_DEV)": {
108 - "size": 269759,
109 - "gzip": 57590
108 + "size": 269773,
109 + "gzip": 57593
110 },
111 "ReactARTFiber-prod.js (FB_PROD)": {
112 - "size": 208039,
113 - "gzip": 43486
112 + "size": 208053,
113 + "gzip": 43488
114 },
115 "ReactNativeStack.js (RN)": {
116 "size": 233993,
@@ -121,20 +121,20 @@
121 "gzip": 84001
122 },
123 "ReactTestRendererFiber-dev.js (FB_DEV)": {
124 - "size": 267261,
125 - "gzip": 56462
124 + "size": 267275,
125 + "gzip": 56465
126 },
127 "ReactTestRendererStack-dev.js (FB_DEV)": {
128 "size": 151770,
129 "gzip": 34846
130 },
131 "react-noop-renderer.development.js (NODE_DEV)": {
132 - "size": 259178,
133 - "gzip": 54431
132 + "size": 259192,
133 + "gzip": 54435
134 },
135 "react-test-renderer.development.js (NODE_DEV)": {
136 - "size": 268012,
137 - "gzip": 56651
136 + "size": 268026,
137 + "gzip": 56654
138 },
139 "react-dom-test-utils.development.js (NODE_DEV)": {
140 "size": 52792,
@@ -155,6 +155,14 @@
155 "ReactShallowRenderer-dev.js (FB_DEV)": {
156 "size": 8063,
157 "gzip": 2229
158 + },
159 + "ReactDOMServerStream-dev.js (FB_DEV)": {
160 + "size": 472917,
161 + "gzip": 113925
162 + },
163 + "ReactDOMServerStream-prod.js (FB_PROD)": {
164 + "size": 345920,
165 + "gzip": 83497
166 }
167 }
168 }
\ No newline at end of file
src/addons/__tests__/ReactDOMFactories-test.js
+5 -3
@@ -17,13 +17,15 @@ var {div} = require('ReactDOMFactories');
17 describe('ReactDOMFactories', () => {
18 it('allow factories to be called without warnings', () => {
19 spyOn(console, 'error');
20 + spyOn(console, 'warn');
21 var element = div();
22 expect(element.type).toBe('div');
23 expect(console.error).not.toHaveBeenCalled();
24 + expect(console.warn).not.toHaveBeenCalled();
25 });
26
27 it('warns once when accessing React.DOM methods', () => {
26 - spyOn(console, 'error');
28 + spyOn(console, 'warn');
29
30 var a = React.DOM.a();
31 var p = React.DOM.p();
@@ -31,8 +33,8 @@ describe('ReactDOMFactories', () => {
33 expect(a.type).toBe('a');
34 expect(p.type).toBe('p');
35
34 - expect(console.error).toHaveBeenCalledTimes(1);
35 - expect(console.error.calls.first().args[0]).toContain(
36 + expect(console.warn).toHaveBeenCalledTimes(1);
37 + expect(console.warn.calls.first().args[0]).toContain(
38 'Warning: Accessing factories like React.DOM.a has been deprecated',
39 );
40 });
src/isomorphic/React.js
+6 -6
@@ -27,7 +27,7 @@ var createFactory = ReactElement.createFactory;
27 var cloneElement = ReactElement.cloneElement;
28
29 if (__DEV__) {
30 - var warning = require('fbjs/lib/warning');
30 + var lowPriorityWarning = require('lowPriorityWarning');
31 var canDefineProperty = require('canDefineProperty');
32 var ReactElementValidator = require('ReactElementValidator');
33 createElement = ReactElementValidator.createElement;
@@ -91,7 +91,7 @@ if (__DEV__) {
91 let warnedForPropTypes = false;
92
93 React.createMixin = function(mixin) {
94 - warning(
94 + lowPriorityWarning(
95 warnedForCreateMixin,
96 'React.createMixin is deprecated and should not be used. You ' +
97 'can use this mixin directly instead.',
@@ -104,7 +104,7 @@ if (__DEV__) {
104 if (canDefineProperty) {
105 Object.defineProperty(React, 'checkPropTypes', {
106 get() {
107 - warning(
107 + lowPriorityWarning(
108 warnedForCheckPropTypes,
109 'checkPropTypes has been moved to a separate package. ' +
110 'Accessing React.checkPropTypes is no longer supported ' +
@@ -119,7 +119,7 @@ if (__DEV__) {
119
120 Object.defineProperty(React, 'createClass', {
121 get: function() {
122 - warning(
122 + lowPriorityWarning(
123 warnedForCreateClass,
124 'React.createClass is no longer supported. Use a plain JavaScript ' +
125 "class instead. If you're not yet ready to migrate, " +
@@ -133,7 +133,7 @@ if (__DEV__) {
133
134 Object.defineProperty(React, 'PropTypes', {
135 get() {
136 - warning(
136 + lowPriorityWarning(
137 warnedForPropTypes,
138 'PropTypes has been moved to a separate package. ' +
139 'Accessing React.PropTypes is no longer supported ' +
@@ -155,7 +155,7 @@ if (__DEV__) {
155 Object.keys(ReactDOMFactories).forEach(function(factory) {
156 React.DOM[factory] = function(...args) {
157 if (!warnedForFactories) {
158 - warning(
158 + lowPriorityWarning(
159 false,
160 'Accessing factories like React.DOM.%s has been deprecated ' +
161 'and will be removed in the future. Use the ' +
src/isomorphic/__tests__/React-test.js
+12 -12
@@ -19,22 +19,22 @@ describe('React', () => {
19 });
20
21 it('should log a deprecation warning once when using React.createMixin', () => {
22 - spyOn(console, 'error');
22 + spyOn(console, 'warn');
23 React.createMixin();
24 React.createMixin();
25 - expectDev(console.error.calls.count()).toBe(1);
26 - expectDev(console.error.calls.argsFor(0)[0]).toContain(
25 + expectDev(console.warn.calls.count()).toBe(1);
26 + expectDev(console.warn.calls.argsFor(0)[0]).toContain(
27 'React.createMixin is deprecated and should not be used',
28 );
29 });
30
31 it('should warn once when attempting to access React.createClass', () => {
32 - spyOn(console, 'error');
32 + spyOn(console, 'warn');
33 let createClass = React.createClass;
34 createClass = React.createClass;
35 expect(createClass).not.toBe(undefined);
36 - expectDev(console.error.calls.count()).toBe(1);
37 - expectDev(console.error.calls.argsFor(0)[0]).toContain(
36 + expectDev(console.warn.calls.count()).toBe(1);
37 + expectDev(console.warn.calls.argsFor(0)[0]).toContain(
38 'React.createClass is no longer supported. Use a plain JavaScript ' +
39 "class instead. If you're not yet ready to migrate, " +
40 'create-react-class is available on npm as a drop-in replacement. ' +
@@ -43,12 +43,12 @@ describe('React', () => {
43 });
44
45 it('should warn once when attempting to access React.PropTypes', () => {
46 - spyOn(console, 'error');
46 + spyOn(console, 'warn');
47 let PropTypes = React.PropTypes;
48 PropTypes = React.PropTypes;
49 expect(PropTypes).not.toBe(undefined);
50 - expectDev(console.error.calls.count()).toBe(1);
51 - expectDev(console.error.calls.argsFor(0)[0]).toContain(
50 + expectDev(console.warn.calls.count()).toBe(1);
51 + expectDev(console.warn.calls.argsFor(0)[0]).toContain(
52 'PropTypes has been moved to a separate package. ' +
53 'Accessing React.PropTypes is no longer supported ' +
54 'and will be removed completely in React 16. ' +
@@ -58,12 +58,12 @@ describe('React', () => {
58 });
59
60 it('should warn once when attempting to access React.checkPropTypes', () => {
61 - spyOn(console, 'error');
61 + spyOn(console, 'warn');
62 let checkPropTypes = React.checkPropTypes;
63 checkPropTypes = React.checkPropTypes;
64 expect(checkPropTypes).not.toBe(undefined);
65 - expectDev(console.error.calls.count()).toBe(1);
66 - expectDev(console.error.calls.argsFor(0)[0]).toContain(
65 + expectDev(console.warn.calls.count()).toBe(1);
66 + expectDev(console.warn.calls.argsFor(0)[0]).toContain(
67 'checkPropTypes has been moved to a separate package. ' +
68 'Accessing React.checkPropTypes is no longer supported ' +
69 'and will be removed completely in React 16. ' +
src/isomorphic/classic/element/ReactElementValidator.js
+3 -2
@@ -27,8 +27,9 @@ var getIteratorFn = require('getIteratorFn');
27
28 if (__DEV__) {
29 var checkPropTypes = require('prop-types/checkPropTypes');
30 - var warning = require('fbjs/lib/warning');
30 + var lowPriorityWarning = require('lowPriorityWarning');
31 var ReactDebugCurrentFrame = require('ReactDebugCurrentFrame');
32 + var warning = require('fbjs/lib/warning');
33 var {getCurrentStackAddendum} = require('ReactComponentTreeHook');
34 }
35
@@ -285,7 +286,7 @@ var ReactElementValidator = {
286 Object.defineProperty(validatedFactory, 'type', {
287 enumerable: false,
288 get: function() {
288 - warning(
289 + lowPriorityWarning(
290 false,
291 'Factory.type is deprecated. Access the class directly ' +
292 'before passing it to createFactory.',
src/isomorphic/classic/element/__tests__/ReactElementValidator-test.js
+4 -4
@@ -441,20 +441,20 @@ describe('ReactElementValidator', () => {
441 });
442
443 it('should warn when accessing .type on an element factory', () => {
444 - spyOn(console, 'error');
444 + spyOn(console, 'warn');
445 function TestComponent() {
446 return <div />;
447 }
448 var TestFactory = React.createFactory(TestComponent);
449 expect(TestFactory.type).toBe(TestComponent);
450 - expectDev(console.error.calls.count()).toBe(1);
451 - expectDev(console.error.calls.argsFor(0)[0]).toBe(
450 + expectDev(console.warn.calls.count()).toBe(1);
451 + expectDev(console.warn.calls.argsFor(0)[0]).toBe(
452 'Warning: Factory.type is deprecated. Access the class directly before ' +
453 'passing it to createFactory.',
454 );
455 // Warn once, not again
456 expect(TestFactory.type).toBe(TestComponent);
457 - expectDev(console.error.calls.count()).toBe(1);
457 + expectDev(console.warn.calls.count()).toBe(1);
458 });
459
460 it('does not warn when using DOM node as children', () => {
src/isomorphic/modern/class/ReactBaseClasses.js
+2 -2
@@ -16,7 +16,7 @@ var ReactNoopUpdateQueue = require('ReactNoopUpdateQueue');
16 var canDefineProperty = require('canDefineProperty');
17 var emptyObject = require('fbjs/lib/emptyObject');
18 var invariant = require('fbjs/lib/invariant');
19 -var warning = require('fbjs/lib/warning');
19 +var lowPriorityWarning = require('lowPriorityWarning');
20
21 /**
22 * Base class helpers for the updating state of a component.
@@ -108,7 +108,7 @@ if (__DEV__) {
108 if (canDefineProperty) {
109 Object.defineProperty(ReactComponent.prototype, methodName, {
110 get: function() {
111 - warning(
111 + lowPriorityWarning(
112 false,
113 '%s(...) is deprecated in plain JavaScript React classes. %s',
114 info[0],
src/isomorphic/modern/class/__tests__/ReactCoffeeScriptClass-test.coffee
+4 -4
@@ -378,16 +378,16 @@ describe 'ReactCoffeeScriptClass', ->
378 undefined
379
380 it 'should throw AND warn when trying to access classic APIs', ->
381 - spyOn console, 'error'
381 + spyOn console, 'warn'
382 instance =
383 test Inner(name: 'foo'), 'DIV', 'foo'
384 expect(-> instance.replaceState {}).toThrow()
385 expect(-> instance.isMounted()).toThrow()
386 - expect(console.error.calls.count()).toBe 2
387 - expect(console.error.calls.argsFor(0)[0]).toContain(
386 + expect(console.warn.calls.count()).toBe 2
387 + expect(console.warn.calls.argsFor(0)[0]).toContain(
388 'replaceState(...) is deprecated in plain JavaScript React classes'
389 )
390 - expect(console.error.calls.argsFor(1)[0]).toContain(
390 + expect(console.warn.calls.argsFor(1)[0]).toContain(
391 'isMounted(...) is deprecated in plain JavaScript React classes'
392 )
393 undefined
src/isomorphic/modern/class/__tests__/ReactES6Class-test.js
+4 -4
@@ -402,15 +402,15 @@ describe('ReactES6Class', () => {
402 });
403
404 it('should throw AND warn when trying to access classic APIs', () => {
405 - spyOn(console, 'error');
405 + spyOn(console, 'warn');
406 var instance = test(<Inner name="foo" />, 'DIV', 'foo');
407 expect(() => instance.replaceState({})).toThrow();
408 expect(() => instance.isMounted()).toThrow();
409 - expect(console.error.calls.count()).toBe(2);
410 - expect(console.error.calls.argsFor(0)[0]).toContain(
409 + expect(console.warn.calls.count()).toBe(2);
410 + expect(console.warn.calls.argsFor(0)[0]).toContain(
411 'replaceState(...) is deprecated in plain JavaScript React classes',
412 );
413 - expect(console.error.calls.argsFor(1)[0]).toContain(
413 + expect(console.warn.calls.argsFor(1)[0]).toContain(
414 'isMounted(...) is deprecated in plain JavaScript React classes',
415 );
416 });
src/isomorphic/modern/class/__tests__/ReactTypeScriptClass-test.ts
+4 -4
@@ -502,18 +502,18 @@ describe('ReactTypeScriptClass', function() {
502 });
503
504 it('should throw AND warn when trying to access classic APIs', function() {
505 - spyOn(console, 'error');
505 + spyOn(console, 'warn');
506 var instance = test(
507 React.createElement(Inner, {name: 'foo'}),
508 'DIV','foo'
509 );
510 expect(() => instance.replaceState({})).toThrow();
511 expect(() => instance.isMounted()).toThrow();
512 - expect((<any>console.error).calls.count()).toBe(2);
513 - expect((<any>console.error).calls.argsFor(0)[0]).toContain(
512 + expect((<any>console.warn).calls.count()).toBe(2);
513 + expect((<any>console.warn).calls.argsFor(0)[0]).toContain(
514 'replaceState(...) is deprecated in plain JavaScript React classes'
515 );
516 - expect((<any>console.error).calls.argsFor(1)[0]).toContain(
516 + expect((<any>console.warn).calls.argsFor(1)[0]).toContain(
517 'isMounted(...) is deprecated in plain JavaScript React classes'
518 );
519 });
src/renderers/__tests__/ReactPerf-test.js
+8 -8
@@ -406,30 +406,30 @@ describeStack('ReactPerf', () => {
406
407 it('warns once when using getMeasurementsSummaryMap', () => {
408 var measurements = measure(() => {});
409 - spyOn(console, 'error');
409 + spyOn(console, 'warn');
410 ReactPerf.getMeasurementsSummaryMap(measurements);
411 - expectDev(console.error.calls.count()).toBe(1);
412 - expectDev(console.error.calls.argsFor(0)[0]).toContain(
411 + expectDev(console.warn.calls.count()).toBe(1);
412 + expectDev(console.warn.calls.argsFor(0)[0]).toContain(
413 '`ReactPerf.getMeasurementsSummaryMap(...)` is deprecated. Use ' +
414 '`ReactPerf.getWasted(...)` instead.',
415 );
416
417 ReactPerf.getMeasurementsSummaryMap(measurements);
418 - expectDev(console.error.calls.count()).toBe(1);
418 + expectDev(console.warn.calls.count()).toBe(1);
419 });
420
421 it('warns once when using printDOM', () => {
422 var measurements = measure(() => {});
423 - spyOn(console, 'error');
423 + spyOn(console, 'warn');
424 ReactPerf.printDOM(measurements);
425 - expectDev(console.error.calls.count()).toBe(1);
426 - expectDev(console.error.calls.argsFor(0)[0]).toContain(
425 + expectDev(console.warn.calls.count()).toBe(1);
426 + expectDev(console.warn.calls.argsFor(0)[0]).toContain(
427 '`ReactPerf.printDOM(...)` is deprecated. Use ' +
428 '`ReactPerf.printOperations(...)` instead.',
429 );
430
431 ReactPerf.printDOM(measurements);
432 - expectDev(console.error.calls.count()).toBe(1);
432 + expectDev(console.warn.calls.count()).toBe(1);
433 });
434
435 it('returns isRunning state', () => {
src/renderers/shared/ReactPerf.js
+3 -3
@@ -13,7 +13,7 @@
13 'use strict';
14
15 var ReactDebugTool = require('ReactDebugTool');
16 -var warning = require('fbjs/lib/warning');
16 +var lowPriorityWarning = require('lowPriorityWarning');
17 var alreadyWarned = false;
18
19 import type {FlushHistory} from 'ReactDebugTool';
@@ -390,7 +390,7 @@ function printOperations(flushHistory?: FlushHistory) {
390
391 var warnedAboutPrintDOM = false;
392 function printDOM(measurements: FlushHistory) {
393 - warning(
393 + lowPriorityWarning(
394 warnedAboutPrintDOM,
395 '`ReactPerf.printDOM(...)` is deprecated. Use ' +
396 '`ReactPerf.printOperations(...)` instead.',
@@ -401,7 +401,7 @@ function printDOM(measurements: FlushHistory) {
401
402 var warnedAboutGetMeasurementsSummaryMap = false;
403 function getMeasurementsSummaryMap(measurements: FlushHistory) {
404 - warning(
404 + lowPriorityWarning(
405 warnedAboutGetMeasurementsSummaryMap,
406 '`ReactPerf.getMeasurementsSummaryMap(...)` is deprecated. Use ' +
407 '`ReactPerf.getWasted(...)` instead.',
src/shared/utils/deprecated.js
+2 -2
@@ -12,7 +12,7 @@
12
13 'use strict';
14
15 -var warning = require('fbjs/lib/warning');
15 +var lowPriorityWarning = require('lowPriorityWarning');
16
17 /**
18 * This will log a single deprecation notice per function and forward the call
@@ -35,7 +35,7 @@ function deprecated<T: Function>(
35 var warned = false;
36 if (__DEV__) {
37 var newFn = function() {
38 - warning(
38 + lowPriorityWarning(
39 warned,
40 /* eslint-disable no-useless-concat */
41 // Require examples in this string must be split to prevent React's
src/shared/utils/lowPriorityWarning.js new
+41
@@ -0,0 +1,41 @@
1 +/**
2 + * Copyright 2014-2015, Facebook, Inc.
3 + * All rights reserved.
4 + *
5 + * This source code is licensed under the BSD-style license found in the
6 + * LICENSE file in the root directory of this source tree. An additional grant
7 + * of patent rights can be found in the PATENTS file in the same directory.
8 + *
9 + * @providesModule lowPriorityWarning
10 + */
11 +
12 +'use strict';
13 +
14 +/**
15 + * Forked from fbjs/warning:
16 + * https://github.com/facebook/fbjs/blob/e66ba20ad5be433eb54423f2b097d829324d9de6/packages/fbjs/src/__forks__/warning.js
17 + *
18 + * Only change is we use console.warn instead of console.error,
19 + * and do nothing when 'console' is not supported.
20 + * This really simplifies the code.
21 + * ---
22 + *
23 + * Similar to invariant but only logs a warning if the condition is not met.
24 + * This can be used to log issues in development environments in critical
25 + * paths. Removing the logging code for production environments will keep the
26 + * same logic and follow the same code paths.
27 + */
28 +
29 +var lowPriorityWarning = function() {};
30 +
31 +if (__DEV__) {
32 + lowPriorityWarning = function(condition, format, ...args) {
33 + var argIndex = 0;
34 + var message = 'Warning: ' + format.replace(/%s/g, () => args[argIndex++]);
35 + if (!condition && typeof console !== 'undefined') {
36 + console.warn(message);
37 + }
38 + };
39 +}
40 +
41 +module.exports = lowPriorityWarning;