ReactElementValidator uses temporary ReactNative View propTypes getter (#9256)

This commit is contained in:
Brian Vaughn
2017-03-24 23:16:24 +00:00
committed by Dan Abramov
parent 60e78e37b8
commit c5156eb0be
@@ -181,8 +181,17 @@ function validatePropTypes(element) {
return;
}
var name = componentClass.displayName || componentClass.name;
if (componentClass.propTypes) {
checkReactTypeSpec(componentClass.propTypes, element.props, 'prop', name);
// ReactNative `View.propTypes` have been deprecated in favor of `ViewPropTypes`.
// In their place a temporary getter has been added with a deprecated warning message.
// Avoid triggering that warning during validation using the temporary workaround, __propTypesSecretDontUseThesePlease.
// TODO (bvaughn) Revert this particular change any time after April 1 ReactNative RC is tagged.
var propTypes = typeof componentClass.__propTypesSecretDontUseThesePlease === 'object'
? componentClass.__propTypesSecretDontUseThesePlease
: componentClass.propTypes;
if (propTypes) {
checkReactTypeSpec(propTypes, element.props, 'prop', name);
}
if (typeof componentClass.getDefaultProps === 'function') {
warning(