From 24a4bd265d711939794bb5fc9511379323ff8b05 Mon Sep 17 00:00:00 2001 From: Brian Vaughn Date: Fri, 24 Mar 2017 14:41:41 -0700 Subject: [PATCH] ReactElementValidator uses temporary ReactNative View propTypes getter --- .../classic/element/ReactElementValidator.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/isomorphic/classic/element/ReactElementValidator.js b/src/isomorphic/classic/element/ReactElementValidator.js index dbe09c81549a..ab606a5a4190 100644 --- a/src/isomorphic/classic/element/ReactElementValidator.js +++ b/src/isomorphic/classic/element/ReactElementValidator.js @@ -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(