mirror of
https://github.com/status-im/react-native.git
synced 2025-01-09 17:15:54 +00:00
5db5ee9f55
Summary:
There were several fixes to how calls to propType checkers. This is to
account for the new deprecation warning - React.PropTypes will not be
part of production builds in the future.
Note: There is still a warning about an invalid argument to `React.PropTypes.oneOf` (React is running that validation sooner now). Specifically [both of these](b1e49832ef/Libraries/Components/Touchable/TouchableWithoutFeedback.js (L44-L45)
) because `View.AccessibilityTraits` is actually undefined in tests (didn't look into why you conditionally set that).
**Test plan (required)**
`npm test` & fixed all warnings due to proptype secret
Closes https://github.com/facebook/react-native/pull/8758
Reviewed By: zpao
Differential Revision: D3564288
Pulled By: bestander
fbshipit-source-id: 1ff1f90907f41855e364048aa730ccd239c522b4
43 lines
1.2 KiB
JavaScript
43 lines
1.2 KiB
JavaScript
/**
|
|
* Copyright (c) 2015-present, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule deprecatedPropType
|
|
* @flow
|
|
*/
|
|
'use strict';
|
|
|
|
const UIManager = require('UIManager');
|
|
const ReactPropTypesSecret = require('react/lib/ReactPropTypesSecret');
|
|
const ReactPropTypeLocations = require('react/lib/ReactPropTypeLocations');
|
|
|
|
/**
|
|
* Adds a deprecation warning when the prop is used.
|
|
*/
|
|
function deprecatedPropType(
|
|
propType: ReactPropsCheckType,
|
|
explanation: string
|
|
): ReactPropsCheckType {
|
|
return function validate(props, propName, componentName) {
|
|
// Don't warn for native components.
|
|
if (!UIManager[componentName] && props[propName] !== undefined) {
|
|
console.warn(`\`${propName}\` supplied to \`${componentName}\` has been deprecated. ${explanation}`);
|
|
}
|
|
|
|
return propType(
|
|
props,
|
|
propName,
|
|
componentName,
|
|
ReactPropTypeLocations.prop,
|
|
null,
|
|
ReactPropTypesSecret
|
|
);
|
|
};
|
|
}
|
|
|
|
module.exports = deprecatedPropType;
|