From 49a86413eb38b4b04790e5ddf05ec6e853c20b90 Mon Sep 17 00:00:00 2001 From: Matt Hargett Date: Fri, 19 Oct 2018 09:39:38 -0700 Subject: [PATCH 1/3] Remove BackAndroid, which has had a deprecation warning and only forwarded to BackHandler since March 2018. --- Libraries/Utilities/BackAndroid.js | 54 ------------------- .../react-native-implementation.js | 3 -- 2 files changed, 57 deletions(-) delete mode 100644 Libraries/Utilities/BackAndroid.js diff --git a/Libraries/Utilities/BackAndroid.js b/Libraries/Utilities/BackAndroid.js deleted file mode 100644 index cf4f0cd6381235..00000000000000 --- a/Libraries/Utilities/BackAndroid.js +++ /dev/null @@ -1,54 +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. - * - * BackAndroid has been moved to BackHandler. This stub calls BackHandler methods - * after generating a warning to remind users to move to the new BackHandler module. - * - * @format - */ - -'use strict'; - -const BackHandler = require('BackHandler'); - -const warning = require('fbjs/lib/warning'); - -/** - * Deprecated. Use BackHandler instead. - */ -const BackAndroid = { - exitApp: function() { - warning( - false, - 'BackAndroid is deprecated. Please use BackHandler instead.', - ); - BackHandler.exitApp(); - }, - - addEventListener: function( - eventName: BackPressEventName, - handler: Function, - ): {remove: () => void} { - warning( - false, - 'BackAndroid is deprecated. Please use BackHandler instead.', - ); - return BackHandler.addEventListener(eventName, handler); - }, - - removeEventListener: function( - eventName: BackPressEventName, - handler: Function, - ): void { - warning( - false, - 'BackAndroid is deprecated. Please use BackHandler instead.', - ); - BackHandler.removeEventListener(eventName, handler); - }, -}; - -module.exports = BackAndroid; diff --git a/Libraries/react-native/react-native-implementation.js b/Libraries/react-native/react-native-implementation.js index 0b76506bb7e941..5926e5989148f0 100644 --- a/Libraries/react-native/react-native-implementation.js +++ b/Libraries/react-native/react-native-implementation.js @@ -195,9 +195,6 @@ module.exports = { get AsyncStorage() { return require('AsyncStorage'); }, - get BackAndroid() { - return require('BackAndroid'); - }, // deprecated: use BackHandler instead get BackHandler() { return require('BackHandler'); }, From 8a8a1e743843e357aa184c99d4bd629fcd441e53 Mon Sep 17 00:00:00 2001 From: Matt Hargett Date: Mon, 22 Oct 2018 17:00:32 -0700 Subject: [PATCH 2/3] Add deprecation warnings in a way that will work for teams who haven't migrated off of haste yet. --- .../Components/TabBarIOS/TabBarIOS.android.js | 14 ++++-- .../Components/TabBarIOS/TabBarIOS.ios.js | 10 ++++ .../TabBarIOS/TabBarItemIOS.android.js | 11 +++++ .../Components/TabBarIOS/TabBarItemIOS.ios.js | 12 ++++- Libraries/Vibration/VibrationIOS.android.js | 5 +- Libraries/Vibration/VibrationIOS.ios.js | 6 ++- RNTester/js/VibrationIOSExample.js | 46 ------------------- 7 files changed, 52 insertions(+), 52 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..c10f027730b538 100644 --- a/Libraries/Components/TabBarIOS/TabBarIOS.android.js +++ b/Libraries/Components/TabBarIOS/TabBarIOS.android.js @@ -12,13 +12,21 @@ const React = require('React'); const StyleSheet = require('StyleSheet'); -const TabBarItemIOS = require('TabBarItemIOS'); const View = require('View'); -class DummyTabBarIOS extends React.Component<$FlowFixMeProps> { - static Item = TabBarItemIOS; +let showedDeprecationWarning = false; +class DummyTabBarIOS extends React.Component<$FlowFixMeProps> { render() { + 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; + } + return ( {this.props.children} diff --git a/Libraries/Components/TabBarIOS/TabBarIOS.ios.js b/Libraries/Components/TabBarIOS/TabBarIOS.ios.js index 7b19a1487081e3..94ca604e47c9ff 100644 --- a/Libraries/Components/TabBarIOS/TabBarIOS.ios.js +++ b/Libraries/Components/TabBarIOS/TabBarIOS.ios.js @@ -68,10 +68,20 @@ type Props = $ReadOnly<{| itemPositioning?: ?('fill' | 'center' | 'auto'), |}>; +let showedDeprecationWarning = false; + class TabBarIOS extends React.Component { static Item = TabBarItemIOS; render() { + 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; + } return ( ; } diff --git a/Libraries/Components/TabBarIOS/TabBarItemIOS.ios.js b/Libraries/Components/TabBarIOS/TabBarItemIOS.ios.js index 430934f24034e0..ee8e04134d2248 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, @@ -122,6 +123,15 @@ class TabBarItemIOS extends React.Component { } render() { + 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; + } + const {style, children, ...props} = this.props; // if the tab has already been shown once, always continue to show it so we 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, - }, -}); From a02c68bb52435bf86a8979283abbb62f46e79ec3 Mon Sep 17 00:00:00 2001 From: Matt Hargett Date: Mon, 22 Oct 2018 17:17:11 -0700 Subject: [PATCH 3/3] Move warning to componentDidMount based on feedback. --- Libraries/Components/TabBarIOS/TabBarIOS.android.js | 4 +++- Libraries/Components/TabBarIOS/TabBarIOS.ios.js | 5 ++++- Libraries/Components/TabBarIOS/TabBarItemIOS.android.js | 4 +++- Libraries/Components/TabBarIOS/TabBarItemIOS.ios.js | 6 ++++-- 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/Libraries/Components/TabBarIOS/TabBarIOS.android.js b/Libraries/Components/TabBarIOS/TabBarIOS.android.js index c10f027730b538..6ac8c2387db6b7 100644 --- a/Libraries/Components/TabBarIOS/TabBarIOS.android.js +++ b/Libraries/Components/TabBarIOS/TabBarIOS.android.js @@ -17,7 +17,7 @@ const View = require('View'); let showedDeprecationWarning = false; class DummyTabBarIOS extends React.Component<$FlowFixMeProps> { - render() { + componentDidMount() { if (!showedDeprecationWarning) { console.warn( 'TabBarIOS and TabBarItemIOS are deprecated and will be removed in a future release. ' + @@ -26,7 +26,9 @@ class DummyTabBarIOS extends React.Component<$FlowFixMeProps> { showedDeprecationWarning = true; } + } + render() { return ( {this.props.children} diff --git a/Libraries/Components/TabBarIOS/TabBarIOS.ios.js b/Libraries/Components/TabBarIOS/TabBarIOS.ios.js index 94ca604e47c9ff..883ed1bd6e11c3 100644 --- a/Libraries/Components/TabBarIOS/TabBarIOS.ios.js +++ b/Libraries/Components/TabBarIOS/TabBarIOS.ios.js @@ -73,7 +73,7 @@ let showedDeprecationWarning = false; class TabBarIOS extends React.Component { static Item = TabBarItemIOS; - render() { + componentDidMount() { if (!showedDeprecationWarning) { console.warn( 'TabBarIOS and TabBarItemIOS are deprecated and will be removed in a future release. ' + @@ -82,6 +82,9 @@ class TabBarIOS extends React.Component { showedDeprecationWarning = true; } + } + + render() { return ( ; } diff --git a/Libraries/Components/TabBarIOS/TabBarItemIOS.ios.js b/Libraries/Components/TabBarIOS/TabBarItemIOS.ios.js index ee8e04134d2248..7fc4fadeac9683 100644 --- a/Libraries/Components/TabBarIOS/TabBarItemIOS.ios.js +++ b/Libraries/Components/TabBarIOS/TabBarItemIOS.ios.js @@ -122,7 +122,7 @@ class TabBarItemIOS extends React.Component { } } - render() { + componentDidMount() { if (!showedDeprecationWarning) { console.warn( 'TabBarIOS and TabBarItemIOS are deprecated and will be removed in a future release. ' + @@ -131,7 +131,9 @@ class TabBarItemIOS extends React.Component { showedDeprecationWarning = true; } - + } + + render() { const {style, children, ...props} = this.props; // if the tab has already been shown once, always continue to show it so we