Remove warnOnRepeat option
Don't need this internally; doubt external users will need it either
Andrew Clark committed
Feb 16, 2017 at 11:28 UTC
6ff5211dee0c1734b20d5ce4cd0a9e665f043d72
3 files changed
+14
-10
src/isomorphic/classic/types/__tests__/ReactPropTypes-test.js
+10
-4
@@ -20,13 +20,19 @@ var ReactTestUtils;
20
var Component;
21
var MyComponent;
22
23
+function resetWarningCache() {
24
+ jest.resetModules();
25
+ checkReactTypeSpec = require('checkReactTypeSpec');
26
+}
27
+
28
function getPropTypeWarningMessage(propTypes, object, componentName) {
29
if (!console.error.calls) {
30
spyOn(console, 'error');
31
} else {
32
console.error.calls.reset();
33
}
29
- checkReactTypeSpec(propTypes, object, 'prop', 'testComponent', null, null, true);
34
+ resetWarningCache();
35
+ checkReactTypeSpec(propTypes, object, 'prop', 'testComponent', null, null);
36
const callCount = console.error.calls.count();
37
if (callCount > 1) {
38
throw new Error('Too many warnings.');
@@ -102,10 +108,10 @@ function expectWarningInDevelopment(declaration, value) {
108
describe('ReactPropTypes', () => {
109
beforeEach(() => {
110
PropTypes = require('ReactPropTypes');
105
- checkReactTypeSpec = require('checkReactTypeSpec');
111
React = require('React');
112
ReactFragment = require('ReactFragment');
113
ReactTestUtils = require('ReactTestUtils');
114
+ resetWarningCache();
115
});
116
117
describe('checkPropTypes', () => {
@@ -117,7 +123,7 @@ describe('ReactPropTypes', () => {
123
},
124
};
125
const props = { foo: 'foo' };
120
- const returnValue = PropTypes.checkPropTypes(propTypes, props, 'prop', 'testComponent', null, true);
126
+ const returnValue = PropTypes.checkPropTypes(propTypes, props, 'prop', 'testComponent', null);
127
expect(console.error.calls.argsFor(0)[0]).toContain('some error');
128
expect(returnValue).toBe(undefined);
129
});
@@ -130,7 +136,7 @@ describe('ReactPropTypes', () => {
136
},
137
};
138
const props = { foo: 'foo' };
133
- const returnValue = PropTypes.checkPropTypes(propTypes, props, 'prop', 'testComponent', null, true);
139
+ const returnValue = PropTypes.checkPropTypes(propTypes, props, 'prop', 'testComponent', null);
140
expect(console.error.calls.argsFor(0)[0]).toContain('some error');
141
expect(returnValue).toBe(undefined);
142
});
src/isomorphic/classic/types/checkPropTypes.js
+2
-3
@@ -27,10 +27,9 @@ var loggedTypeFailures = {};
27
* @param {string} location e.g. "prop", "context", "child context"
28
* @param {string} componentName Name of the component for error messages.
29
* @param {?Function} formatMessage Function that transforms the error message, to add additional info.
30
- * @param {?boolean} warnOnRepeat Whether or not repeated warnings should be skipped.
30
* @private
31
*/
33
-function checkPropTypes(typeSpecs, values, location, componentName, formatMessage, warnOnRepeat) {
32
+function checkPropTypes(typeSpecs, values, location, componentName, formatMessage) {
33
for (var typeSpecName in typeSpecs) {
34
if (typeSpecs.hasOwnProperty(typeSpecName)) {
35
var error;
@@ -64,7 +63,7 @@ function checkPropTypes(typeSpecs, values, location, componentName, formatMessag
63
typeSpecName,
64
typeof error
65
);
67
- if (error instanceof Error && (warnOnRepeat || !(error.message in loggedTypeFailures))) {
66
+ if (error instanceof Error && !(error.message in loggedTypeFailures)) {
67
// Only monitor this failure once because there tends to be a lot of the
68
// same error.
69
loggedTypeFailures[error.message] = true;
src/shared/types/checkReactTypeSpec.js
+2
-3
@@ -36,8 +36,7 @@ function checkReactTypeSpec(
36
element,
37
// It is only safe to pass fiber if it is the work-in-progress version, and
38
// only during reconciliation (begin and complete phase).
39
- workInProgressOrDebugID,
40
- warnOnRepeat
39
+ workInProgressOrDebugID
40
) {
41
function formatMessage(message) {
42
if (__DEV__) {
@@ -65,7 +64,7 @@ function checkReactTypeSpec(
64
return message;
65
}
66
68
- checkPropTypes(typeSpecs, values, location, componentName, formatMessage, warnOnRepeat);
67
+ checkPropTypes(typeSpecs, values, location, componentName, formatMessage);
68
}
69
70
module.exports = checkReactTypeSpec;