Add deprecation warnings for a few IOS components
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/21901 Differential Revision: D10502816 Pulled By: TheSavior fbshipit-source-id: 1890aa35251cff0ac2c15760ecd5aabeb7652558
This commit is contained in:
parent
ec6829087e
commit
174644846d
|
@ -15,9 +15,22 @@ const StyleSheet = require('StyleSheet');
|
|||
const TabBarItemIOS = require('TabBarItemIOS');
|
||||
const View = require('View');
|
||||
|
||||
let showedDeprecationWarning = false;
|
||||
|
||||
class DummyTabBarIOS extends React.Component<$FlowFixMeProps> {
|
||||
static Item = TabBarItemIOS;
|
||||
|
||||
componentDidMount() {
|
||||
if (!showedDeprecationWarning) {
|
||||
console.warn(
|
||||
'TabBarIOS and TabBarItemIOS are deprecated and will be removed in a future release. ' +
|
||||
'Please use react-native-tab-view instead.',
|
||||
);
|
||||
|
||||
showedDeprecationWarning = true;
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<View style={[this.props.style, styles.tabGroup]}>
|
||||
|
|
|
@ -68,9 +68,22 @@ type Props = $ReadOnly<{|
|
|||
itemPositioning?: ?('fill' | 'center' | 'auto'),
|
||||
|}>;
|
||||
|
||||
let showedDeprecationWarning = false;
|
||||
|
||||
class TabBarIOS extends React.Component<Props> {
|
||||
static Item = TabBarItemIOS;
|
||||
|
||||
componentDidMount() {
|
||||
if (!showedDeprecationWarning) {
|
||||
console.warn(
|
||||
'TabBarIOS and TabBarItemIOS are deprecated and will be removed in a future release. ' +
|
||||
'Please use react-native-tab-view instead.',
|
||||
);
|
||||
|
||||
showedDeprecationWarning = true;
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<RCTTabBar
|
||||
|
|
|
@ -13,7 +13,20 @@ const React = require('React');
|
|||
const View = require('View');
|
||||
const StyleSheet = require('StyleSheet');
|
||||
|
||||
let showedDeprecationWarning = false;
|
||||
|
||||
class DummyTab extends React.Component {
|
||||
componentDidMount() {
|
||||
if (!showedDeprecationWarning) {
|
||||
console.warn(
|
||||
'TabBarIOS and TabBarItemIOS are deprecated and will be removed in a future release. ' +
|
||||
'Please use react-native-tab-view instead.',
|
||||
);
|
||||
|
||||
showedDeprecationWarning = true;
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
if (!this.props.selected) {
|
||||
return <View />;
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
|
||||
'use strict';
|
||||
|
||||
const Image = require('Image');
|
||||
const React = require('React');
|
||||
const StaticContainer = require('StaticContainer.react');
|
||||
const StyleSheet = require('StyleSheet');
|
||||
|
@ -104,6 +103,8 @@ type State = {|
|
|||
hasBeenSelected: boolean,
|
||||
|};
|
||||
|
||||
let showedDeprecationWarning = false;
|
||||
|
||||
class TabBarItemIOS extends React.Component<Props, State> {
|
||||
state = {
|
||||
hasBeenSelected: false,
|
||||
|
@ -121,6 +122,17 @@ class TabBarItemIOS extends React.Component<Props, State> {
|
|||
}
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
if (!showedDeprecationWarning) {
|
||||
console.warn(
|
||||
'TabBarIOS and TabBarItemIOS are deprecated and will be removed in a future release. ' +
|
||||
'Please use react-native-tab-view instead.',
|
||||
);
|
||||
|
||||
showedDeprecationWarning = true;
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
const {style, children, ...props} = this.props;
|
||||
|
||||
|
|
|
@ -15,7 +15,10 @@ const warning = require('fbjs/lib/warning');
|
|||
|
||||
const VibrationIOS = {
|
||||
vibrate: function() {
|
||||
warning('VibrationIOS is not supported on this platform!');
|
||||
warning(
|
||||
false,
|
||||
'VibrationIOS is deprecated, and will be removed. Use Vibration instead.',
|
||||
);
|
||||
},
|
||||
};
|
||||
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @format
|
||||
* @flow strict-local
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
@ -13,6 +12,7 @@
|
|||
const RCTVibration = require('NativeModules').Vibration;
|
||||
|
||||
const invariant = require('fbjs/lib/invariant');
|
||||
const warning = require('fbjs/lib/warning');
|
||||
|
||||
/**
|
||||
* NOTE: `VibrationIOS` is being deprecated. Use `Vibration` instead.
|
||||
|
@ -32,6 +32,10 @@ const VibrationIOS = {
|
|||
* @deprecated
|
||||
*/
|
||||
vibrate: function() {
|
||||
warning(
|
||||
false,
|
||||
'VibrationIOS is deprecated and will be removed. Please use Vibration instead.',
|
||||
);
|
||||
invariant(arguments[0] === undefined, 'Vibration patterns not supported.');
|
||||
RCTVibration.vibrate();
|
||||
},
|
||||
|
|
|
@ -1,46 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @format
|
||||
* @flow strict-local
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var React = require('react');
|
||||
var ReactNative = require('react-native');
|
||||
var {StyleSheet, View, Text, TouchableHighlight, VibrationIOS} = ReactNative;
|
||||
|
||||
exports.framework = 'React';
|
||||
exports.title = 'VibrationIOS';
|
||||
exports.description = 'Vibration API for iOS';
|
||||
exports.examples = [
|
||||
{
|
||||
title: 'VibrationIOS.vibrate()',
|
||||
render() {
|
||||
return (
|
||||
<TouchableHighlight
|
||||
style={styles.wrapper}
|
||||
onPress={() => VibrationIOS.vibrate()}>
|
||||
<View style={styles.button}>
|
||||
<Text>Vibrate</Text>
|
||||
</View>
|
||||
</TouchableHighlight>
|
||||
);
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
var styles = StyleSheet.create({
|
||||
wrapper: {
|
||||
borderRadius: 5,
|
||||
marginBottom: 5,
|
||||
},
|
||||
button: {
|
||||
backgroundColor: '#eeeeee',
|
||||
padding: 10,
|
||||
},
|
||||
});
|
Loading…
Reference in New Issue