Skip to content

Commit 1746448

Browse files
matthargettfacebook-github-bot
authored andcommitted
Add deprecation warnings for a few IOS components
Summary: Pull Request resolved: #21901 Differential Revision: D10502816 Pulled By: TheSavior fbshipit-source-id: 1890aa35251cff0ac2c15760ecd5aabeb7652558
1 parent ec68290 commit 1746448

File tree

7 files changed

+61
-49
lines changed

7 files changed

+61
-49
lines changed

Libraries/Components/TabBarIOS/TabBarIOS.android.js

+13
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,22 @@ const StyleSheet = require('StyleSheet');
1515
const TabBarItemIOS = require('TabBarItemIOS');
1616
const View = require('View');
1717

18+
let showedDeprecationWarning = false;
19+
1820
class DummyTabBarIOS extends React.Component<$FlowFixMeProps> {
1921
static Item = TabBarItemIOS;
2022

23+
componentDidMount() {
24+
if (!showedDeprecationWarning) {
25+
console.warn(
26+
'TabBarIOS and TabBarItemIOS are deprecated and will be removed in a future release. ' +
27+
'Please use react-native-tab-view instead.',
28+
);
29+
30+
showedDeprecationWarning = true;
31+
}
32+
}
33+
2134
render() {
2235
return (
2336
<View style={[this.props.style, styles.tabGroup]}>

Libraries/Components/TabBarIOS/TabBarIOS.ios.js

+13
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,22 @@ type Props = $ReadOnly<{|
6868
itemPositioning?: ?('fill' | 'center' | 'auto'),
6969
|}>;
7070

71+
let showedDeprecationWarning = false;
72+
7173
class TabBarIOS extends React.Component<Props> {
7274
static Item = TabBarItemIOS;
7375

76+
componentDidMount() {
77+
if (!showedDeprecationWarning) {
78+
console.warn(
79+
'TabBarIOS and TabBarItemIOS are deprecated and will be removed in a future release. ' +
80+
'Please use react-native-tab-view instead.',
81+
);
82+
83+
showedDeprecationWarning = true;
84+
}
85+
}
86+
7487
render() {
7588
return (
7689
<RCTTabBar

Libraries/Components/TabBarIOS/TabBarItemIOS.android.js

+13
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,20 @@ const React = require('React');
1313
const View = require('View');
1414
const StyleSheet = require('StyleSheet');
1515

16+
let showedDeprecationWarning = false;
17+
1618
class DummyTab extends React.Component {
19+
componentDidMount() {
20+
if (!showedDeprecationWarning) {
21+
console.warn(
22+
'TabBarIOS and TabBarItemIOS are deprecated and will be removed in a future release. ' +
23+
'Please use react-native-tab-view instead.',
24+
);
25+
26+
showedDeprecationWarning = true;
27+
}
28+
}
29+
1730
render() {
1831
if (!this.props.selected) {
1932
return <View />;

Libraries/Components/TabBarIOS/TabBarItemIOS.ios.js

+13-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
'use strict';
1212

13-
const Image = require('Image');
1413
const React = require('React');
1514
const StaticContainer = require('StaticContainer.react');
1615
const StyleSheet = require('StyleSheet');
@@ -104,6 +103,8 @@ type State = {|
104103
hasBeenSelected: boolean,
105104
|};
106105

106+
let showedDeprecationWarning = false;
107+
107108
class TabBarItemIOS extends React.Component<Props, State> {
108109
state = {
109110
hasBeenSelected: false,
@@ -121,6 +122,17 @@ class TabBarItemIOS extends React.Component<Props, State> {
121122
}
122123
}
123124

125+
componentDidMount() {
126+
if (!showedDeprecationWarning) {
127+
console.warn(
128+
'TabBarIOS and TabBarItemIOS are deprecated and will be removed in a future release. ' +
129+
'Please use react-native-tab-view instead.',
130+
);
131+
132+
showedDeprecationWarning = true;
133+
}
134+
}
135+
124136
render() {
125137
const {style, children, ...props} = this.props;
126138

Libraries/Vibration/VibrationIOS.android.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ const warning = require('fbjs/lib/warning');
1515

1616
const VibrationIOS = {
1717
vibrate: function() {
18-
warning('VibrationIOS is not supported on this platform!');
18+
warning(
19+
false,
20+
'VibrationIOS is deprecated, and will be removed. Use Vibration instead.',
21+
);
1922
},
2023
};
2124

Libraries/Vibration/VibrationIOS.ios.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
* LICENSE file in the root directory of this source tree.
66
*
77
* @format
8-
* @flow strict-local
98
*/
109

1110
'use strict';
1211

1312
const RCTVibration = require('NativeModules').Vibration;
1413

1514
const invariant = require('fbjs/lib/invariant');
15+
const warning = require('fbjs/lib/warning');
1616

1717
/**
1818
* NOTE: `VibrationIOS` is being deprecated. Use `Vibration` instead.
@@ -32,6 +32,10 @@ const VibrationIOS = {
3232
* @deprecated
3333
*/
3434
vibrate: function() {
35+
warning(
36+
false,
37+
'VibrationIOS is deprecated and will be removed. Please use Vibration instead.',
38+
);
3539
invariant(arguments[0] === undefined, 'Vibration patterns not supported.');
3640
RCTVibration.vibrate();
3741
},

RNTester/js/VibrationIOSExample.js

-46
This file was deleted.

0 commit comments

Comments
 (0)