mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Remove warnOnRepeat option
Don't need this internally; doubt external users will need it either
This commit is contained in:
@@ -20,13 +20,19 @@ var ReactTestUtils;
|
||||
var Component;
|
||||
var MyComponent;
|
||||
|
||||
function resetWarningCache() {
|
||||
jest.resetModules();
|
||||
checkReactTypeSpec = require('checkReactTypeSpec');
|
||||
}
|
||||
|
||||
function getPropTypeWarningMessage(propTypes, object, componentName) {
|
||||
if (!console.error.calls) {
|
||||
spyOn(console, 'error');
|
||||
} else {
|
||||
console.error.calls.reset();
|
||||
}
|
||||
checkReactTypeSpec(propTypes, object, 'prop', 'testComponent', null, null, true);
|
||||
resetWarningCache();
|
||||
checkReactTypeSpec(propTypes, object, 'prop', 'testComponent', null, null);
|
||||
const callCount = console.error.calls.count();
|
||||
if (callCount > 1) {
|
||||
throw new Error('Too many warnings.');
|
||||
@@ -102,10 +108,10 @@ function expectWarningInDevelopment(declaration, value) {
|
||||
describe('ReactPropTypes', () => {
|
||||
beforeEach(() => {
|
||||
PropTypes = require('ReactPropTypes');
|
||||
checkReactTypeSpec = require('checkReactTypeSpec');
|
||||
React = require('React');
|
||||
ReactFragment = require('ReactFragment');
|
||||
ReactTestUtils = require('ReactTestUtils');
|
||||
resetWarningCache();
|
||||
});
|
||||
|
||||
describe('checkPropTypes', () => {
|
||||
@@ -117,7 +123,7 @@ describe('ReactPropTypes', () => {
|
||||
},
|
||||
};
|
||||
const props = { foo: 'foo' };
|
||||
const returnValue = PropTypes.checkPropTypes(propTypes, props, 'prop', 'testComponent', null, true);
|
||||
const returnValue = PropTypes.checkPropTypes(propTypes, props, 'prop', 'testComponent', null);
|
||||
expect(console.error.calls.argsFor(0)[0]).toContain('some error');
|
||||
expect(returnValue).toBe(undefined);
|
||||
});
|
||||
@@ -130,7 +136,7 @@ describe('ReactPropTypes', () => {
|
||||
},
|
||||
};
|
||||
const props = { foo: 'foo' };
|
||||
const returnValue = PropTypes.checkPropTypes(propTypes, props, 'prop', 'testComponent', null, true);
|
||||
const returnValue = PropTypes.checkPropTypes(propTypes, props, 'prop', 'testComponent', null);
|
||||
expect(console.error.calls.argsFor(0)[0]).toContain('some error');
|
||||
expect(returnValue).toBe(undefined);
|
||||
});
|
||||
|
||||
@@ -27,10 +27,9 @@ var loggedTypeFailures = {};
|
||||
* @param {string} location e.g. "prop", "context", "child context"
|
||||
* @param {string} componentName Name of the component for error messages.
|
||||
* @param {?Function} formatMessage Function that transforms the error message, to add additional info.
|
||||
* @param {?boolean} warnOnRepeat Whether or not repeated warnings should be skipped.
|
||||
* @private
|
||||
*/
|
||||
function checkPropTypes(typeSpecs, values, location, componentName, formatMessage, warnOnRepeat) {
|
||||
function checkPropTypes(typeSpecs, values, location, componentName, formatMessage) {
|
||||
for (var typeSpecName in typeSpecs) {
|
||||
if (typeSpecs.hasOwnProperty(typeSpecName)) {
|
||||
var error;
|
||||
@@ -64,7 +63,7 @@ function checkPropTypes(typeSpecs, values, location, componentName, formatMessag
|
||||
typeSpecName,
|
||||
typeof error
|
||||
);
|
||||
if (error instanceof Error && (warnOnRepeat || !(error.message in loggedTypeFailures))) {
|
||||
if (error instanceof Error && !(error.message in loggedTypeFailures)) {
|
||||
// Only monitor this failure once because there tends to be a lot of the
|
||||
// same error.
|
||||
loggedTypeFailures[error.message] = true;
|
||||
|
||||
@@ -36,8 +36,7 @@ function checkReactTypeSpec(
|
||||
element,
|
||||
// It is only safe to pass fiber if it is the work-in-progress version, and
|
||||
// only during reconciliation (begin and complete phase).
|
||||
workInProgressOrDebugID,
|
||||
warnOnRepeat
|
||||
workInProgressOrDebugID
|
||||
) {
|
||||
function formatMessage(message) {
|
||||
if (__DEV__) {
|
||||
@@ -65,7 +64,7 @@ function checkReactTypeSpec(
|
||||
return message;
|
||||
}
|
||||
|
||||
checkPropTypes(typeSpecs, values, location, componentName, formatMessage, warnOnRepeat);
|
||||
checkPropTypes(typeSpecs, values, location, componentName, formatMessage);
|
||||
}
|
||||
|
||||
module.exports = checkReactTypeSpec;
|
||||
|
||||
Reference in New Issue
Block a user