Skip to content

Commit

Permalink
LinkedValueUtils should only export checkPropTypes in dev
Browse files Browse the repository at this point in the history
- all the usage of `LinkedValueUtils.checkPropTypes` are under `__DEV__`
- if we can use named exports this won't be an issue anymore
  • Loading branch information
Keyan Zhang committed Jul 5, 2016
1 parent 80aceea commit 5ee5a97
Showing 1 changed file with 23 additions and 21 deletions.
44 changes: 23 additions & 21 deletions src/renderers/dom/client/wrappers/LinkedValueUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,27 +102,6 @@ function getDeclarationErrorAddendum(owner) {
* this outside of the ReactDOM controlled form components.
*/
var LinkedValueUtils = {
checkPropTypes: function(tagName, props, owner) {
for (var propName in propTypes) {
if (propTypes.hasOwnProperty(propName)) {
var error = propTypes[propName](
props,
propName,
tagName,
ReactPropTypeLocations.prop
);
}
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;

var addendum = getDeclarationErrorAddendum(owner);
warning(false, 'Failed form propType: %s%s', error.message, addendum);
}
}
},

/**
* @param {object} inputProps Props for form component
* @return {*} current value of the input either from value prop or link.
Expand Down Expand Up @@ -165,4 +144,27 @@ var LinkedValueUtils = {
},
};

if (__DEV__) {
LinkedValueUtils.checkPropTypes = function(tagName, props, owner) {
for (var propName in propTypes) {
if (propTypes.hasOwnProperty(propName)) {
var error = propTypes[propName](
props,
propName,
tagName,
ReactPropTypeLocations.prop
);
}
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;

var addendum = getDeclarationErrorAddendum(owner);
warning(false, 'Failed form propType: %s%s', error.message, addendum);
}
}
};
}

module.exports = LinkedValueUtils;

0 comments on commit 5ee5a97

Please sign in to comment.