Skip to content

Commit

Permalink
Revert "Warn if PropType function is called manually (facebook#7132)"
Browse files Browse the repository at this point in the history
This reverts commit e75e8dc.
  • Loading branch information
gaearon committed Oct 24, 2016
1 parent f565aef commit be71f76
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 271 deletions.
5 changes: 0 additions & 5 deletions src/addons/link/__tests__/ReactLinkPropTypes-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
var emptyFunction = require('emptyFunction');
var LinkPropTypes = require('ReactLink').PropTypes;
var React = require('React');
var ReactPropTypesSecret = require('ReactPropTypesSecret');

var invalidMessage = 'Invalid prop `testProp` supplied to `testComponent`.';
var requiredMessage = 'The prop `testProp` is marked as required in ' +
Expand All @@ -27,8 +26,6 @@ function typeCheckFail(declaration, value, message) {
'testProp',
'testComponent',
'prop',
null,
ReactPropTypesSecret
);
expect(error instanceof Error).toBe(true);
expect(error.message).toBe(message);
Expand All @@ -41,8 +38,6 @@ function typeCheckPass(declaration, value) {
'testProp',
'testComponent',
'prop',
null,
ReactPropTypesSecret
);
expect(error).toBe(null);
}
Expand Down
64 changes: 7 additions & 57 deletions src/isomorphic/classic/types/ReactPropTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

var ReactElement = require('ReactElement');
var ReactPropTypeLocationNames = require('ReactPropTypeLocationNames');
var ReactPropTypesSecret = require('ReactPropTypesSecret');

var emptyFunction = require('emptyFunction');
var getIteratorFn = require('getIteratorFn');
Expand Down Expand Up @@ -153,42 +152,16 @@ function PropTypeError(message) {
PropTypeError.prototype = Error.prototype;

function createChainableTypeChecker(validate) {
if (__DEV__) {
var manualPropTypeCallCache = {};
}
function checkType(
isRequired,
props,
propName,
componentName,
location,
propFullName,
secret
propFullName
) {
componentName = componentName || ANONYMOUS;
propFullName = propFullName || propName;
if (__DEV__) {
if (
secret !== ReactPropTypesSecret &&
typeof console !== 'undefined'
) {
var cacheKey = `${componentName}:${propName}`;
if (!manualPropTypeCallCache[cacheKey]) {
warning(
false,
'You are manually calling a React.PropTypes validation ' +
'function for the `%s` prop on `%s`. This is deprecated ' +
'and will not work in production with the next major version. ' +
'You may be seeing this warning due to a third-party PropTypes ' +
'library. See https://fb.me/react-warning-dont-call-proptypes ' +
'for details.',
propFullName,
componentName
);
manualPropTypeCallCache[cacheKey] = true;
}
}
}
if (props[propName] == null) {
var locationName = ReactPropTypeLocationNames[location];
if (isRequired) {
Expand All @@ -205,13 +178,7 @@ function createChainableTypeChecker(validate) {
}
return null;
} else {
return validate(
props,
propName,
componentName,
location,
propFullName,
);
return validate(props, propName, componentName, location, propFullName);
}
}

Expand All @@ -222,14 +189,7 @@ function createChainableTypeChecker(validate) {
}

function createPrimitiveTypeChecker(expectedType) {
function validate(
props,
propName,
componentName,
location,
propFullName,
secret
) {
function validate(props, propName, componentName, location, propFullName) {
var propValue = props[propName];
var propType = getPropType(propValue);
if (propType !== expectedType) {
Expand Down Expand Up @@ -276,8 +236,7 @@ function createArrayOfTypeChecker(typeChecker) {
i,
componentName,
location,
`${propFullName}[${i}]`,
ReactPropTypesSecret
`${propFullName}[${i}]`
);
if (error instanceof Error) {
return error;
Expand Down Expand Up @@ -368,8 +327,7 @@ function createObjectOfTypeChecker(typeChecker) {
key,
componentName,
location,
`${propFullName}.${key}`,
ReactPropTypesSecret
`${propFullName}.${key}`
);
if (error instanceof Error) {
return error;
Expand All @@ -391,14 +349,7 @@ function createUnionTypeChecker(arrayOfTypeCheckers) {
for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
var checker = arrayOfTypeCheckers[i];
if (
checker(
props,
propName,
componentName,
location,
propFullName,
ReactPropTypesSecret
) == null
checker(props, propName, componentName, location, propFullName) == null
) {
return null;
}
Expand Down Expand Up @@ -448,8 +399,7 @@ function createShapeTypeChecker(shapeTypes) {
key,
componentName,
location,
`${propFullName}.${key}`,
ReactPropTypesSecret
`${propFullName}.${key}`
);
if (error) {
return error;
Expand Down

0 comments on commit be71f76

Please sign in to comment.