mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-28 20:25:33 +08:00
Add a deprecatedPropType module to show deprecation warnings
Summary: To allow smoother API changes for users we often deprecate props and keep them around for a while before removing them. Right now it is all done manually, this adds a consistent way to show a warning when using a deprecated prop. This also adds a deprecation warning of the website generated from the deprecatedPropType. <img width="643" alt="screen shot 2016-01-26 at 7 43 08 pm" src="https://cloud.githubusercontent.com/assets/2677334/12600172/7af28fb0-c465-11e5-85e5-3786852bf522.png"> It also changes places where we added the warnings manually to use deprecatedPropType instead. Closes https://github.com/facebook/react-native/pull/5566 Reviewed By: svcscm Differential Revision: D2874629 Pulled By: nicklockwood fb-gh-sync-id: c3c63bae7bbec26cc146029abd9aa5efbe73f795
This commit is contained in:
committed by
facebook-github-bot-3
parent
8de86a0d65
commit
1c6e837504
@@ -22,6 +22,7 @@ const React = require('React');
|
||||
const StyleSheet = require('StyleSheet');
|
||||
const View = require('View');
|
||||
|
||||
const deprecatedPropType = require('deprecatedPropType');
|
||||
const processColor = require('processColor');
|
||||
const resolveAssetSource = require('resolveAssetSource');
|
||||
const requireNativeComponent = require('requireNativeComponent');
|
||||
@@ -64,7 +65,7 @@ const MapView = React.createClass({
|
||||
* @platform ios
|
||||
*/
|
||||
followUserLocation: React.PropTypes.bool,
|
||||
|
||||
|
||||
/**
|
||||
* If `false` points of interest won't be displayed on the map.
|
||||
* Default value is `true`.
|
||||
@@ -160,7 +161,7 @@ const MapView = React.createClass({
|
||||
* Whether the pin drop should be animated or not
|
||||
*/
|
||||
animateDrop: React.PropTypes.bool,
|
||||
|
||||
|
||||
/**
|
||||
* Whether the pin should be draggable or not
|
||||
*/
|
||||
@@ -168,7 +169,7 @@ const MapView = React.createClass({
|
||||
|
||||
/**
|
||||
* Event that fires when the annotation drag state changes.
|
||||
*/
|
||||
*/
|
||||
onDragStateChange: React.PropTypes.func,
|
||||
|
||||
/**
|
||||
@@ -213,11 +214,22 @@ const MapView = React.createClass({
|
||||
/**
|
||||
* Deprecated. Use the left/right/detailsCalloutView props instead.
|
||||
*/
|
||||
hasLeftCallout: React.PropTypes.bool,
|
||||
hasRightCallout: React.PropTypes.bool,
|
||||
onLeftCalloutPress: React.PropTypes.func,
|
||||
onRightCalloutPress: React.PropTypes.func,
|
||||
|
||||
hasLeftCallout: deprecatedPropType(
|
||||
React.PropTypes.bool,
|
||||
'Use `leftCalloutView` instead.'
|
||||
),
|
||||
hasRightCallout: deprecatedPropType(
|
||||
React.PropTypes.bool,
|
||||
'Use `rightCalloutView` instead.'
|
||||
),
|
||||
onLeftCalloutPress: deprecatedPropType(
|
||||
React.PropTypes.func,
|
||||
'Use `leftCalloutView` instead.'
|
||||
),
|
||||
onRightCalloutPress: deprecatedPropType(
|
||||
React.PropTypes.func,
|
||||
'Use `rightCalloutView` instead.'
|
||||
),
|
||||
})),
|
||||
|
||||
/**
|
||||
@@ -335,18 +347,7 @@ const MapView = React.createClass({
|
||||
style: [styles.calloutView, detailCalloutView.props.style || {}]
|
||||
}));
|
||||
}
|
||||
if (__DEV__) {
|
||||
['hasLeftCallout', 'onLeftCalloutPress'].forEach(key => {
|
||||
if (annotation[key]) {
|
||||
console.warn('`' + key + '` is deprecated. Use leftCalloutView instead.');
|
||||
}
|
||||
});
|
||||
['hasRightCallout', 'onRightCalloutPress'].forEach(key => {
|
||||
if (annotation[key]) {
|
||||
console.warn('`' + key + '` is deprecated. Use rightCalloutView instead.');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
let result = {
|
||||
...annotation,
|
||||
tintColor: tintColor && processColor(tintColor),
|
||||
|
||||
@@ -25,6 +25,7 @@ var View = require('View');
|
||||
var ViewStylePropTypes = require('ViewStylePropTypes');
|
||||
|
||||
var deepDiffer = require('deepDiffer');
|
||||
var deprecatedPropType = require('deprecatedPropType');
|
||||
var dismissKeyboard = require('dismissKeyboard');
|
||||
var flattenStyle = require('flattenStyle');
|
||||
var insetsDiffer = require('insetsDiffer');
|
||||
@@ -321,10 +322,12 @@ var ScrollView = React.createClass({
|
||||
refreshControl: PropTypes.element,
|
||||
|
||||
/**
|
||||
* Deprecated - use `refreshControl` property instead.
|
||||
* @platform ios
|
||||
*/
|
||||
onRefreshStart: PropTypes.func,
|
||||
onRefreshStart: deprecatedPropType(
|
||||
PropTypes.func,
|
||||
'Use the `refreshControl` prop instead.'
|
||||
),
|
||||
},
|
||||
|
||||
mixins: [ScrollResponder.Mixin],
|
||||
@@ -464,7 +467,6 @@ var ScrollView = React.createClass({
|
||||
|
||||
var onRefreshStart = this.props.onRefreshStart;
|
||||
if (onRefreshStart) {
|
||||
console.warn('onRefreshStart is deprecated. Use the refreshControl prop instead.');
|
||||
// this is necessary because if we set it on props, even when empty,
|
||||
// it'll trigger the default pull-to-refresh behavior on native.
|
||||
props.onRefreshStart =
|
||||
|
||||
Reference in New Issue
Block a user