Skip to content

Add deprecation warnings for a few IOS components #21901

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions Libraries/Components/TabBarIOS/TabBarIOS.android.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,21 @@

const React = require('React');
const StyleSheet = require('StyleSheet');
const TabBarItemIOS = require('TabBarItemIOS');
const View = require('View');

let showedDeprecationWarning = false;

class DummyTabBarIOS extends React.Component<$FlowFixMeProps> {
static Item = TabBarItemIOS;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing this caused Flow errors on Android:

Error ---------------------------------------------------------------------------
react-native/RNTester/js/TabBarIOSBarStyleExample.js:40:10
Cannot get `TabBarIOS.Item` because property `Item` is missing in statics of `DummyTabBarIOS` [1].
  react-native/RNTester/js/TabBarIOSBarStyleExample.js:40:10
  40|         <TabBarIOS.Item title="Tab" icon={{uri: base64Icon, scale: 3}} selected>
               ^^^^^^^^^^^^^^
References:
  react-native/Libraries/Components/TabBarIOS/TabBarIOS.android.js:19:7
  19| class DummyTabBarIOS extends React.Component<$FlowFixMeProps> {
            ^^^^^^^^^^^^^^ [1]
Error -------- react-native/RNTester/js/TabBarIOSExample.js:49:10
Cannot get `TabBarIOS.Item` because property `Item` is missing in statics of `DummyTabBarIOS` [1].
  react-native/RNTester/js/TabBarIOSExample.js:49:10
  49|         <TabBarIOS.Item
               ^^^^^^^^^^^^^^
References:
  react-native/Libraries/Components/TabBarIOS/TabBarIOS.android.js:19:7
  19| class DummyTabBarIOS extends React.Component<$FlowFixMeProps> {
            ^^^^^^^^^^^^^^ [1]
Error -------- react-native/RNTester/js/TabBarIOSExample.js:60:10
Cannot get `TabBarIOS.Item` because property `Item` is missing in statics of `DummyTabBarIOS` [1].
  react-native/RNTester/js/TabBarIOSExample.js:60:10
  60|         <TabBarIOS.Item
               ^^^^^^^^^^^^^^
References:
  react-native/Libraries/Components/TabBarIOS/TabBarIOS.android.js:19:7
  19| class DummyTabBarIOS extends React.Component<$FlowFixMeProps> {
            ^^^^^^^^^^^^^^ [1]
Error -------- react-native/RNTester/js/TabBarIOSExample.js:73:10
Cannot get `TabBarIOS.Item` because property `Item` is missing in statics of `DummyTabBarIOS` [1].
  react-native/RNTester/js/TabBarIOSExample.js:73:10
  73|         <TabBarIOS.Item
               ^^^^^^^^^^^^^^
References:
  react-native/Libraries/Components/TabBarIOS/TabBarIOS.android.js:19:7
  19| class DummyTabBarIOS extends React.Component<$FlowFixMeProps> {
            ^^^^^^^^^^^^^^ [1]
Found 4 errors

I'll fix it

componentDidMount() {
if (!showedDeprecationWarning) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do you feel about the different places this could go? At the top level, constructor, componentDidMount, render. My feeling is that I'd prefer constructor or componentDidMount but I'm curious if you had thought about this already.

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 (
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.