From 6ff5211dee0c1734b20d5ce4cd0a9e665f043d72 Mon Sep 17 00:00:00 2001 From: Andrew Clark Date: Thu, 16 Feb 2017 11:28:20 -0800 Subject: [PATCH] Remove warnOnRepeat option Don't need this internally; doubt external users will need it either --- .../classic/types/__tests__/ReactPropTypes-test.js | 14 ++++++++++---- src/isomorphic/classic/types/checkPropTypes.js | 5 ++--- src/shared/types/checkReactTypeSpec.js | 5 ++--- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/isomorphic/classic/types/__tests__/ReactPropTypes-test.js b/src/isomorphic/classic/types/__tests__/ReactPropTypes-test.js index 6a1aba0b8a..0653fae8a7 100644 --- a/src/isomorphic/classic/types/__tests__/ReactPropTypes-test.js +++ b/src/isomorphic/classic/types/__tests__/ReactPropTypes-test.js @@ -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); }); diff --git a/src/isomorphic/classic/types/checkPropTypes.js b/src/isomorphic/classic/types/checkPropTypes.js index d38468f38b..b0d53a1ac7 100644 --- a/src/isomorphic/classic/types/checkPropTypes.js +++ b/src/isomorphic/classic/types/checkPropTypes.js @@ -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; diff --git a/src/shared/types/checkReactTypeSpec.js b/src/shared/types/checkReactTypeSpec.js index 819ab91a9a..663a18274a 100644 --- a/src/shared/types/checkReactTypeSpec.js +++ b/src/shared/types/checkReactTypeSpec.js @@ -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;