Skip to content

Commit

Permalink
Revert "Warn if PropType function is called manually (#7132)"
Browse files Browse the repository at this point in the history
This reverts commit e75e8dc.
  • Loading branch information
gaearon committed Sep 3, 2016
1 parent f4c9a04 commit 9539d71
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 277 deletions.
9 changes: 2 additions & 7 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 @@ -26,9 +25,7 @@ function typeCheckFail(declaration, value, message) {
props,
'testProp',
'testComponent',
'prop',
null,
ReactPropTypesSecret
'prop'
);
expect(error instanceof Error).toBe(true);
expect(error.message).toBe(message);
Expand All @@ -40,9 +37,7 @@ function typeCheckPass(declaration, value) {
props,
'testProp',
'testComponent',
'prop',
null,
ReactPropTypesSecret
'prop'
);
expect(error).toBe(null);
}
Expand Down
63 changes: 7 additions & 56 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,41 +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 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 @@ -204,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 @@ -221,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 @@ -275,8 +236,7 @@ function createArrayOfTypeChecker(typeChecker) {
i,
componentName,
location,
`${propFullName}[${i}]`,
ReactPropTypesSecret
`${propFullName}[${i}]`
);
if (error instanceof Error) {
return error;
Expand Down Expand Up @@ -367,8 +327,7 @@ function createObjectOfTypeChecker(typeChecker) {
key,
componentName,
location,
`${propFullName}.${key}`,
ReactPropTypesSecret
`${propFullName}.${key}`
);
if (error instanceof Error) {
return error;
Expand All @@ -390,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 @@ -447,8 +399,7 @@ function createShapeTypeChecker(shapeTypes) {
key,
componentName,
location,
`${propFullName}.${key}`,
ReactPropTypesSecret
`${propFullName}.${key}`
);
if (error) {
return error;
Expand Down
Loading

0 comments on commit 9539d71

Please sign in to comment.