From 174644846d7f0b2729d2a538695a42ae8c057946 Mon Sep 17 00:00:00 2001 From: Matt Hargett Date: Mon, 22 Oct 2018 23:15:29 -0700 Subject: [PATCH] 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 --- .../Components/TabBarIOS/TabBarIOS.android.js | 13 ++++++ .../Components/TabBarIOS/TabBarIOS.ios.js | 13 ++++++ .../TabBarIOS/TabBarItemIOS.android.js | 13 ++++++ .../Components/TabBarIOS/TabBarItemIOS.ios.js | 14 +++++- Libraries/Vibration/VibrationIOS.android.js | 5 +- Libraries/Vibration/VibrationIOS.ios.js | 6 ++- RNTester/js/VibrationIOSExample.js | 46 ------------------- 7 files changed, 61 insertions(+), 49 deletions(-) delete mode 100644 RNTester/js/VibrationIOSExample.js diff --git a/Libraries/Components/TabBarIOS/TabBarIOS.android.js b/Libraries/Components/TabBarIOS/TabBarIOS.android.js index 58da238b4b7019..81047bfe95d2cb 100644 --- a/Libraries/Components/TabBarIOS/TabBarIOS.android.js +++ b/Libraries/Components/TabBarIOS/TabBarIOS.android.js @@ -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 ( diff --git a/Libraries/Components/TabBarIOS/TabBarIOS.ios.js b/Libraries/Components/TabBarIOS/TabBarIOS.ios.js index 7b19a1487081e3..883ed1bd6e11c3 100644 --- a/Libraries/Components/TabBarIOS/TabBarIOS.ios.js +++ b/Libraries/Components/TabBarIOS/TabBarIOS.ios.js @@ -68,9 +68,22 @@ type Props = $ReadOnly<{| itemPositioning?: ?('fill' | 'center' | 'auto'), |}>; +let showedDeprecationWarning = false; + class TabBarIOS extends React.Component { 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 ( ; diff --git a/Libraries/Components/TabBarIOS/TabBarItemIOS.ios.js b/Libraries/Components/TabBarIOS/TabBarItemIOS.ios.js index 430934f24034e0..7fc4fadeac9683 100644 --- a/Libraries/Components/TabBarIOS/TabBarItemIOS.ios.js +++ b/Libraries/Components/TabBarIOS/TabBarItemIOS.ios.js @@ -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 { state = { hasBeenSelected: false, @@ -121,6 +122,17 @@ class TabBarItemIOS 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() { const {style, children, ...props} = this.props; diff --git a/Libraries/Vibration/VibrationIOS.android.js b/Libraries/Vibration/VibrationIOS.android.js index e9acfb49582446..f87869a6b3daa0 100644 --- a/Libraries/Vibration/VibrationIOS.android.js +++ b/Libraries/Vibration/VibrationIOS.android.js @@ -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.', + ); }, }; diff --git a/Libraries/Vibration/VibrationIOS.ios.js b/Libraries/Vibration/VibrationIOS.ios.js index b3e59cb04a8ec8..23548423cc19c1 100644 --- a/Libraries/Vibration/VibrationIOS.ios.js +++ b/Libraries/Vibration/VibrationIOS.ios.js @@ -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(); }, diff --git a/RNTester/js/VibrationIOSExample.js b/RNTester/js/VibrationIOSExample.js deleted file mode 100644 index 15f3414de90dc8..00000000000000 --- a/RNTester/js/VibrationIOSExample.js +++ /dev/null @@ -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 ( - VibrationIOS.vibrate()}> - - Vibrate - - - ); - }, - }, -]; - -var styles = StyleSheet.create({ - wrapper: { - borderRadius: 5, - marginBottom: 5, - }, - button: { - backgroundColor: '#eeeeee', - padding: 10, - }, -});