Skip to content

Commit

Permalink
Add deprecation warnings for a few IOS components
Browse files Browse the repository at this point in the history
Summary: Pull Request resolved: facebook#21901

Differential Revision: D10502816

Pulled By: TheSavior

fbshipit-source-id: 1890aa35251cff0ac2c15760ecd5aabeb7652558
  • Loading branch information
matthargett authored and facebook-github-bot committed Oct 23, 2018
1 parent e90d03f commit 6f6b62e
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 49 deletions.
13 changes: 13 additions & 0 deletions Libraries/Components/TabBarIOS/TabBarIOS.android.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]}>
Expand Down
13 changes: 13 additions & 0 deletions Libraries/Components/TabBarIOS/TabBarIOS.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 13 additions & 0 deletions Libraries/Components/TabBarIOS/TabBarItemIOS.android.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 />;
Expand Down
14 changes: 13 additions & 1 deletion Libraries/Components/TabBarIOS/TabBarItemIOS.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

'use strict';

const Image = require('Image');
const React = require('React');
const StaticContainer = require('StaticContainer.react');
const StyleSheet = require('StyleSheet');
Expand Down Expand Up @@ -104,6 +103,8 @@ type State = {|
hasBeenSelected: boolean,
|};

let showedDeprecationWarning = false;

class TabBarItemIOS extends React.Component<Props, State> {
state = {
hasBeenSelected: false,
Expand All @@ -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;

Expand Down
5 changes: 4 additions & 1 deletion Libraries/Vibration/VibrationIOS.android.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.',
);
},
};

Expand Down
6 changes: 5 additions & 1 deletion Libraries/Vibration/VibrationIOS.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
* LICENSE file in the root directory of this source tree.
*
* @format
* @flow strict-local
*/

'use strict';

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.
Expand All @@ -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();
},
Expand Down
46 changes: 0 additions & 46 deletions RNTester/js/VibrationIOSExample.js

This file was deleted.

0 comments on commit 6f6b62e

Please sign in to comment.