ReactElementValidator uses temporary ReactNative View propTypes getter (#9256)
Brian Vaughn committed
Mar 24, 2017 at 15:37 UTC
1acf949240f30a9492838e39a9112dc1d7a50e77
1 file changed
+11
-2
src/isomorphic/classic/element/ReactElementValidator.js
+11
-2
@@ -181,8 +181,17 @@ function validatePropTypes(element) {
181
return;
182
}
183
var name = componentClass.displayName || componentClass.name;
184
- if (componentClass.propTypes) {
185
- checkReactTypeSpec(componentClass.propTypes, element.props, 'prop', name);
184
+
185
+ // ReactNative `View.propTypes` have been deprecated in favor of `ViewPropTypes`.
186
+ // In their place a temporary getter has been added with a deprecated warning message.
187
+ // Avoid triggering that warning during validation using the temporary workaround, __propTypesSecretDontUseThesePlease.
188
+ // TODO (bvaughn) Revert this particular change any time after April 1 ReactNative RC is tagged.
189
+ var propTypes = typeof componentClass.__propTypesSecretDontUseThesePlease === 'object'
190
+ ? componentClass.__propTypesSecretDontUseThesePlease
191
+ : componentClass.propTypes;
192
+
193
+ if (propTypes) {
194
+ checkReactTypeSpec(propTypes, element.props, 'prop', name);
195
}
196
if (typeof componentClass.getDefaultProps === 'function') {
197
warning(