From fa5ad85252be9e5e5a8f04d705463e7ba4cb85e3 Mon Sep 17 00:00:00 2001 From: Satyajit Sahoo Date: Tue, 11 Oct 2016 07:35:49 -0700 Subject: [PATCH] Remove deprecated APIs and modules Summary: We've deprecated these APIs for quite a few releases and we should be able to get rid of them now. Remove following deprecated modules/components - AppStateIOS - ActivityIndicatorIOS - IntentAndroid - SliderIOS - SwitchAndroid - SwitchIOS - LinkingIOS Update following modules to remove callback support - Clipboard - NetInfo cc bestander Closes https://github.com/facebook/react-native/pull/9891 Reviewed By: bestander Differential Revision: D3974094 Pulled By: javache fbshipit-source-id: 9abe32716bd85d0cea9933894f4447d53bdd5ee7 --- .../js/ToolbarAndroidExample.android.js | 4 +- Libraries/AppState/AppStateIOS.js | 18 -- .../ActivityIndicatorIOS.android.js | 22 --- .../ActivityIndicatorIOS.ios.js | 63 ------- Libraries/Components/Clipboard/Clipboard.js | 8 +- .../Intent/IntentAndroid.android.js | 142 --------------- .../Components/Intent/IntentAndroid.ios.js | 17 -- .../Components/SliderIOS/SliderIOS.android.js | 14 -- .../Components/SliderIOS/SliderIOS.ios.js | 161 ------------------ .../SwitchAndroid/SwitchAndroid.android.js | 93 ---------- .../SwitchAndroid/SwitchAndroid.ios.js | 13 -- .../Components/SwitchIOS/SwitchIOS.android.js | 46 ----- .../Components/SwitchIOS/SwitchIOS.ios.js | 120 ------------- Libraries/LinkingIOS/LinkingIOS.js | 18 -- Libraries/Network/NetInfo.js | 10 +- Libraries/Utilities/deprecatedCallback.js | 54 ------ Libraries/react-native/react-native.js | 7 - .../src/androidTest/js/TestIdTestModule.js | 6 +- website/server/extractDocs.js | 24 +-- 19 files changed, 18 insertions(+), 822 deletions(-) delete mode 100644 Libraries/AppState/AppStateIOS.js delete mode 100644 Libraries/Components/ActivityIndicator/ActivityIndicatorIOS.android.js delete mode 100644 Libraries/Components/ActivityIndicator/ActivityIndicatorIOS.ios.js delete mode 100644 Libraries/Components/Intent/IntentAndroid.android.js delete mode 100644 Libraries/Components/Intent/IntentAndroid.ios.js delete mode 100644 Libraries/Components/SliderIOS/SliderIOS.android.js delete mode 100644 Libraries/Components/SliderIOS/SliderIOS.ios.js delete mode 100644 Libraries/Components/SwitchAndroid/SwitchAndroid.android.js delete mode 100644 Libraries/Components/SwitchAndroid/SwitchAndroid.ios.js delete mode 100644 Libraries/Components/SwitchIOS/SwitchIOS.android.js delete mode 100644 Libraries/Components/SwitchIOS/SwitchIOS.ios.js delete mode 100644 Libraries/LinkingIOS/LinkingIOS.js delete mode 100644 Libraries/Utilities/deprecatedCallback.js diff --git a/Examples/UIExplorer/js/ToolbarAndroidExample.android.js b/Examples/UIExplorer/js/ToolbarAndroidExample.android.js index 39941eed9da..8ae9aab288b 100644 --- a/Examples/UIExplorer/js/ToolbarAndroidExample.android.js +++ b/Examples/UIExplorer/js/ToolbarAndroidExample.android.js @@ -32,7 +32,7 @@ var { var UIExplorerBlock = require('./UIExplorerBlock'); var UIExplorerPage = require('./UIExplorerPage'); -var SwitchAndroid = require('SwitchAndroid'); +var Switch = require('Switch'); var ToolbarAndroid = require('ToolbarAndroid'); class ToolbarAndroidExample extends React.Component { @@ -67,7 +67,7 @@ class ToolbarAndroidExample extends React.Component { logo={require('image!launcher_icon')} style={styles.toolbar}> - this.setState({'toolbarSwitch': value})} /> {'\'Tis but a switch'} diff --git a/Libraries/AppState/AppStateIOS.js b/Libraries/AppState/AppStateIOS.js deleted file mode 100644 index c2c29969e7a..00000000000 --- a/Libraries/AppState/AppStateIOS.js +++ /dev/null @@ -1,18 +0,0 @@ -/** - * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - * - * @providesModule AppStateIOS - * @flow - */ -'use strict'; - -const AppState = require('AppState'); - -console.warn('AppStateIOS is deprecated. Use AppState instead'); - -module.exports = AppState; diff --git a/Libraries/Components/ActivityIndicator/ActivityIndicatorIOS.android.js b/Libraries/Components/ActivityIndicator/ActivityIndicatorIOS.android.js deleted file mode 100644 index 1e7f01cee1b..00000000000 --- a/Libraries/Components/ActivityIndicator/ActivityIndicatorIOS.android.js +++ /dev/null @@ -1,22 +0,0 @@ -/** - * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - * - * @providesModule ActivityIndicatorIOS - */ -'use strict'; - -var React = require('React'); -var View = require('View'); - -class ActivityIndicatorIOS extends React.Component { - render(): ReactElement { - return ; - } -} - -module.exports = ActivityIndicatorIOS; diff --git a/Libraries/Components/ActivityIndicator/ActivityIndicatorIOS.ios.js b/Libraries/Components/ActivityIndicator/ActivityIndicatorIOS.ios.js deleted file mode 100644 index 4386dc46f4c..00000000000 --- a/Libraries/Components/ActivityIndicator/ActivityIndicatorIOS.ios.js +++ /dev/null @@ -1,63 +0,0 @@ -/** - * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - * - * @providesModule ActivityIndicatorIOS - */ -'use strict'; - -var ActivityIndicator = require('ActivityIndicator'); -var NativeMethodsMixin = require('react/lib/NativeMethodsMixin'); -var PropTypes = require('react/lib/ReactPropTypes'); -var React = require('React'); -var View = require('View'); - -/** - * Deprecated, use ActivityIndicator instead. - */ -var ActivityIndicatorIOS = React.createClass({ - mixins: [NativeMethodsMixin], - - propTypes: { - ...View.propTypes, - /** - * Whether to show the indicator (true, the default) or hide it (false). - */ - animating: PropTypes.bool, - /** - * The foreground color of the spinner (default is gray). - */ - color: PropTypes.string, - /** - * Whether the indicator should hide when not animating (true by default). - */ - hidesWhenStopped: PropTypes.bool, - /** - * Size of the indicator. Small has a height of 20, large has a height of 36. - */ - size: PropTypes.oneOf([ - 'small', - 'large', - ]), - /** - * Invoked on mount and layout changes with - * - * {nativeEvent: { layout: {x, y, width, height}}}. - */ - onLayout: PropTypes.func, - }, - - componentDidMount: function() { - console.warn('ActivityIndicatorIOS is deprecated. Use ActivityIndicator instead.'); - }, - - render: function() { - return ; - } -}); - -module.exports = ActivityIndicatorIOS; diff --git a/Libraries/Components/Clipboard/Clipboard.js b/Libraries/Components/Clipboard/Clipboard.js index 1a1e157238a..ac8641c8347 100644 --- a/Libraries/Components/Clipboard/Clipboard.js +++ b/Libraries/Components/Clipboard/Clipboard.js @@ -12,7 +12,6 @@ 'use strict'; const Clipboard = require('NativeModules').Clipboard; -const deprecatedCallback = require('deprecatedCallback'); /** * `Clipboard` gives you an interface for setting and getting content from Clipboard on both iOS and Android @@ -27,12 +26,7 @@ module.exports = { * ``` */ getString(): Promise { - return deprecatedCallback( - Clipboard.getString(), - Array.prototype.slice.call(arguments), - 'success-first', - 'Clipboard.getString(callback) is deprecated. Use the returned Promise instead' - ); + return Clipboard.getString(); }, /** * Set content of string type. You can use following code to set clipboard content diff --git a/Libraries/Components/Intent/IntentAndroid.android.js b/Libraries/Components/Intent/IntentAndroid.android.js deleted file mode 100644 index 0e563d2860d..00000000000 --- a/Libraries/Components/Intent/IntentAndroid.android.js +++ /dev/null @@ -1,142 +0,0 @@ -/** - * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - * - * @providesModule IntentAndroid - * @flow - */ -'use strict'; - -var Linking = require('Linking'); -var invariant = require('fbjs/lib/invariant'); - -/** - * NOTE: `IntentAndroid` is being deprecated. Use `Linking` instead. - * - * `IntentAndroid` gives you a general interface to handle external links. - * - * ### Basic Usage - * - * #### Handling deep links - * - * If your app was launched from an external url registered to your app you can - * access and handle it from any component you want with - * - * ``` - * componentDidMount() { - * var url = IntentAndroid.getInitialURL(url => { - * if (url) { - * console.log('Initial url is: ' + url); - * } - * }); - * } - * ``` - * - * Example to add support for deep linking inside your React Native app. - * More Info: [Enabling Deep Links for App Content - Add Intent Filters for Your Deep Links](http://developer.android.com/training/app-indexing/deep-linking.html#adding-filters). - * - * Edit in `android/app/src/main/AndroidManifest.xml` - * - * ``` - * - * - * - * - * - * - * - * - * - * - * - * - * ``` - * - * #### Opening external links - * - * To start the corresponding activity for a link (web URL, email, contact etc.), call - * - * ``` - * IntentAndroid.openURL(url) - * ``` - * - * If you want to check if any installed app can handle a given URL beforehand you can call - * ``` - * IntentAndroid.canOpenURL(url, (supported) => { - * if (!supported) { - * console.log('Can\'t handle url: ' + url); - * } else { - * IntentAndroid.openURL(url); - * } - * }); - * ``` - */ -class IntentAndroid { - - /** - * Starts a corresponding external activity for the given URL. - * - * For example, if the URL is "https://www.facebook.com", the system browser will be opened, - * or the "choose application" dialog will be shown. - * - * You can use other URLs, like a location (e.g. "geo:37.484847,-122.148386"), a contact, - * or any other URL that can be opened with {@code Intent.ACTION_VIEW}. - * - * NOTE: This method will fail if the system doesn't know how to open the specified URL. - * If you're passing in a non-http(s) URL, it's best to check {@code canOpenURL} first. - * - * NOTE: For web URLs, the protocol ("http://", "https://") must be set accordingly! - * - * @deprecated - */ - static openURL(url: string) { - console.warn('"IntentAndroid.openURL" is deprecated. Use the promise based "Linking.openURL" instead.'); - Linking.openURL(url); - } - - /** - * Determine whether or not an installed app can handle a given URL. - * - * You can use other URLs, like a location (e.g. "geo:37.484847,-122.148386"), a contact, - * or any other URL that can be opened with {@code Intent.ACTION_VIEW}. - * - * NOTE: For web URLs, the protocol ("http://", "https://") must be set accordingly! - * - * @param URL the URL to open - * - * @deprecated - */ - static canOpenURL(url: string, callback: Function) { - console.warn('"IntentAndroid.canOpenURL" is deprecated. Use the promise based "Linking.canOpenURL" instead.'); - invariant( - typeof callback === 'function', - 'A valid callback function is required' - ); - Linking.canOpenURL(url).then(callback); - } - - /** - * If the app launch was triggered by an app link with {@code Intent.ACTION_VIEW}, - * it will give the link url, otherwise it will give `null` - * - * Refer http://developer.android.com/training/app-indexing/deep-linking.html#handling-intents - * - * @deprecated - */ - static getInitialURL(callback: Function) { - console.warn('"IntentAndroid.getInitialURL" is deprecated. Use the promise based "Linking.getInitialURL" instead.'); - invariant( - typeof callback === 'function', - 'A valid callback function is required' - ); - Linking.getInitialURL().then(callback); - } -} - -module.exports = IntentAndroid; diff --git a/Libraries/Components/Intent/IntentAndroid.ios.js b/Libraries/Components/Intent/IntentAndroid.ios.js deleted file mode 100644 index 8b4af29ae6e..00000000000 --- a/Libraries/Components/Intent/IntentAndroid.ios.js +++ /dev/null @@ -1,17 +0,0 @@ -/** - * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - * - * @providesModule IntentAndroid - */ -'use strict'; - -module.exports = { - openURL: function(url) { - console.error('IntentAndroid is not supported on iOS'); - }, -}; diff --git a/Libraries/Components/SliderIOS/SliderIOS.android.js b/Libraries/Components/SliderIOS/SliderIOS.android.js deleted file mode 100644 index 714972f9883..00000000000 --- a/Libraries/Components/SliderIOS/SliderIOS.android.js +++ /dev/null @@ -1,14 +0,0 @@ -/** - * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - * - * @providesModule SliderIOS - */ - -'use strict'; - -module.exports = require('UnimplementedView'); diff --git a/Libraries/Components/SliderIOS/SliderIOS.ios.js b/Libraries/Components/SliderIOS/SliderIOS.ios.js deleted file mode 100644 index 8ef48c6416a..00000000000 --- a/Libraries/Components/SliderIOS/SliderIOS.ios.js +++ /dev/null @@ -1,161 +0,0 @@ -/** - * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - * - * @providesModule SliderIOS - * @flow - */ -'use strict'; - -var Image = require('Image'); -var NativeMethodsMixin = require('react/lib/NativeMethodsMixin'); -var PropTypes = require('react/lib/ReactPropTypes'); -var React = require('React'); -var StyleSheet = require('StyleSheet'); -var View = require('View'); - -var requireNativeComponent = require('requireNativeComponent'); - -type Event = Object; - -/** - * **Note:** SliderIOS is deprecated and will be removed in the future. Use the cross-platform - * Slider as a drop-in replacement with the same API. - * - * An iOS-specific component used to select a single value from a range of values. - */ -var SliderIOS = React.createClass({ - mixins: [NativeMethodsMixin], - - propTypes: { - ...View.propTypes, - /** - * Used to style and layout the `Slider`. See `StyleSheet.js` and - * `ViewStylePropTypes.js` for more info. - */ - style: View.propTypes.style, - - /** - * Initial value of the slider. The value should be between minimumValue - * and maximumValue, which default to 0 and 1 respectively. - * Default value is 0. - * - * *This is not a controlled component*, e.g. if you don't update - * the value, the component won't be reset to its initial value. - */ - value: PropTypes.number, - - /** - * Step value of the slider. The value should be - * between 0 and (maximumValue - minimumValue). - * Default value is 0. - */ - step: PropTypes.number, - - /** - * Initial minimum value of the slider. Default value is 0. - */ - minimumValue: PropTypes.number, - - /** - * Initial maximum value of the slider. Default value is 1. - */ - maximumValue: PropTypes.number, - - /** - * The color used for the track to the left of the button. Overrides the - * default blue gradient image. - */ - minimumTrackTintColor: PropTypes.string, - - /** - * The color used for the track to the right of the button. Overrides the - * default blue gradient image. - */ - maximumTrackTintColor: PropTypes.string, - - /** - * If true the user won't be able to move the slider. - * Default value is false. - */ - disabled: PropTypes.bool, - - /** - * Assigns a single image for the track. Only static images are supported. - * The center pixel of the image will be stretched to fill the track. - */ - trackImage: Image.propTypes.source, - - /** - * Assigns a minimum track image. Only static images are supported. The - * rightmost pixel of the image will be stretched to fill the track. - */ - minimumTrackImage: Image.propTypes.source, - - /** - * Assigns a maximum track image. Only static images are supported. The - * leftmost pixel of the image will be stretched to fill the track. - */ - maximumTrackImage: Image.propTypes.source, - - /** - * Sets an image for the thumb. It only supports static images. - */ - thumbImage: Image.propTypes.source, - - /** - * Callback continuously called while the user is dragging the slider. - */ - onValueChange: PropTypes.func, - - /** - * Callback called when the user finishes changing the value (e.g. when - * the slider is released). - */ - onSlidingComplete: PropTypes.func, - }, - - getDefaultProps: function() : any { - return { - disabled: false, - }; - }, - - render: function() { - console.warn( - 'SliderIOS is deprecated and will be removed in ' + - 'future versions of React Native. Use the cross-platform Slider ' + - 'as a drop-in replacement.'); - - const {style, onValueChange, onSlidingComplete, ...props} = this.props; - props.style = [styles.slider, style]; - - props.onValueChange = onValueChange && ((event: Event) => { - onValueChange && onValueChange(event.nativeEvent.value); - }); - - props.onSlidingComplete = onSlidingComplete && ((event: Event) => { - onSlidingComplete && onSlidingComplete(event.nativeEvent.value); - }); - - return true} - onResponderTerminationRequest={() => false} - />; - } -}); - -var styles = StyleSheet.create({ - slider: { - height: 40, - }, -}); - -var RCTSlider = requireNativeComponent('RCTSlider', SliderIOS); - -module.exports = SliderIOS; diff --git a/Libraries/Components/SwitchAndroid/SwitchAndroid.android.js b/Libraries/Components/SwitchAndroid/SwitchAndroid.android.js deleted file mode 100644 index 90b87537989..00000000000 --- a/Libraries/Components/SwitchAndroid/SwitchAndroid.android.js +++ /dev/null @@ -1,93 +0,0 @@ -/** - * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - * - * @providesModule SwitchAndroid - */ -'use strict'; - -var NativeMethodsMixin = require('react/lib/NativeMethodsMixin'); -var PropTypes = require('react/lib/ReactPropTypes'); -var React = require('React'); -var View = require('View'); - -var requireNativeComponent = require('requireNativeComponent'); - -var SWITCH = 'switch'; - -/** - * @deprecated - * - * Use instead for cross-platform compatibility. - */ -var SwitchAndroid = React.createClass({ - mixins: [NativeMethodsMixin], - - propTypes: { - ...View.propTypes, - /** - * Boolean value of the switch. - */ - value: PropTypes.bool, - /** - * If `true`, this component can't be interacted with. - */ - disabled: PropTypes.bool, - /** - * Invoked with the new value when the value changes. - */ - onValueChange: PropTypes.func, - /** - * Used to locate this view in end-to-end tests. - */ - testID: PropTypes.string, - }, - - getDefaultProps: function() { - return { - value: false, - disabled: false, - }; - }, - - _onChange: function(event) { - // The underlying switch might have changed, but we're controlled, - // and so want to ensure it represents our value. - this.refs[SWITCH].setNativeProps({on: this.props.value}); - - if (this.props.value === event.nativeEvent.value || this.props.disabled) { - return; - } - - this.props.onChange && this.props.onChange(event); - this.props.onValueChange && this.props.onValueChange(event.nativeEvent.value); - }, - - render: function() { - return ( - true} - onResponderTerminationRequest={() => false} - /> - ); - } -}); - -var RKSwitch = requireNativeComponent('AndroidSwitch', SwitchAndroid, { - nativeOnly: { - on: true, - enabled: true, - } -}); - -module.exports = SwitchAndroid; diff --git a/Libraries/Components/SwitchAndroid/SwitchAndroid.ios.js b/Libraries/Components/SwitchAndroid/SwitchAndroid.ios.js deleted file mode 100644 index d14807207b5..00000000000 --- a/Libraries/Components/SwitchAndroid/SwitchAndroid.ios.js +++ /dev/null @@ -1,13 +0,0 @@ -/** - * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - * - * @providesModule SwitchAndroid - */ -'use strict'; - -module.exports = require('UnimplementedView'); diff --git a/Libraries/Components/SwitchIOS/SwitchIOS.android.js b/Libraries/Components/SwitchIOS/SwitchIOS.android.js deleted file mode 100644 index ea670d3e257..00000000000 --- a/Libraries/Components/SwitchIOS/SwitchIOS.android.js +++ /dev/null @@ -1,46 +0,0 @@ -/** - * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - * - * @providesModule SwitchIOS - */ - -'use strict'; - -var React = require('React'); -var StyleSheet = require('StyleSheet'); -var Text = require('Text'); -var View = require('View'); - -class DummySwitchIOS extends React.Component { - render() { - return ( - - SwitchIOS is not supported on this platform! - - ); - } -} - -var styles = StyleSheet.create({ - dummySwitchIOS: { - width: 120, - height: 50, - backgroundColor: '#ffbcbc', - borderWidth: 1, - borderColor: 'red', - alignItems: 'center', - justifyContent: 'center', - }, - text: { - color: '#333333', - margin: 5, - fontSize: 10, - } -}); - -module.exports = DummySwitchIOS; diff --git a/Libraries/Components/SwitchIOS/SwitchIOS.ios.js b/Libraries/Components/SwitchIOS/SwitchIOS.ios.js deleted file mode 100644 index 761a9196160..00000000000 --- a/Libraries/Components/SwitchIOS/SwitchIOS.ios.js +++ /dev/null @@ -1,120 +0,0 @@ -/** - * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - * - * @providesModule SwitchIOS - * @flow - * - * This is a controlled component version of RCTSwitch. - */ -'use strict'; - -var ColorPropType = require('ColorPropType'); -var NativeMethodsMixin = require('react/lib/NativeMethodsMixin'); -var PropTypes = require('react/lib/ReactPropTypes'); -var React = require('React'); -var StyleSheet = require('StyleSheet'); -var View = require('View'); - -var requireNativeComponent = require('requireNativeComponent'); - -var SWITCH = 'switch'; - -type DefaultProps = { - value: boolean, - disabled: boolean, -}; - -type Event = Object; - -/** - * @deprecated - * - * Use instead for cross-platform compatibility. - */ -var SwitchIOS = React.createClass({ - mixins: [NativeMethodsMixin], - - propTypes: { - ...View.propTypes, - /** - * The value of the switch, if true the switch will be turned on. - * Default value is false. - */ - value: PropTypes.bool, - - /** - * If true the user won't be able to toggle the switch. - * Default value is false. - */ - disabled: PropTypes.bool, - - /** - * Callback that is called when the user toggles the switch. - */ - onValueChange: PropTypes.func, - - /** - * Background color when the switch is turned on. - */ - onTintColor: ColorPropType, - - /** - * Background color for the switch round button. - */ - thumbTintColor: ColorPropType, - - /** - * Background color when the switch is turned off. - */ - tintColor: ColorPropType, - }, - - getDefaultProps: function(): DefaultProps { - return { - value: false, - disabled: false, - }; - }, - - _onChange: function(event: Event) { - // The underlying switch might have changed, but we're controlled, - // and so want to ensure it represents our value. - this.refs[SWITCH].setNativeProps({value: this.props.value}); - - if (this.props.value === event.nativeEvent.value || this.props.disabled) { - return; - } - - this.props.onChange && this.props.onChange(event); - this.props.onValueChange && this.props.onValueChange(event.nativeEvent.value); - }, - - render: function() { - return ( - - ); - } -}); - -var styles = StyleSheet.create({ - rkSwitch: { - height: 31, - width: 51, - }, -}); - -var RCTSwitch = requireNativeComponent('RCTSwitch', SwitchIOS, { - nativeOnly: { onChange: true } -}); - -module.exports = SwitchIOS; diff --git a/Libraries/LinkingIOS/LinkingIOS.js b/Libraries/LinkingIOS/LinkingIOS.js deleted file mode 100644 index 19730186257..00000000000 --- a/Libraries/LinkingIOS/LinkingIOS.js +++ /dev/null @@ -1,18 +0,0 @@ -/** - * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - * - * @providesModule LinkingIOS - * @flow - */ -'use strict'; - -var Linking = require('Linking'); - -console.warn('LinkingIOS is deprecated. Use Linking instead'); - -module.exports = Linking; diff --git a/Libraries/Network/NetInfo.js b/Libraries/Network/NetInfo.js index 02b500414f3..1ef0ead287d 100644 --- a/Libraries/Network/NetInfo.js +++ b/Libraries/Network/NetInfo.js @@ -16,7 +16,6 @@ const NativeEventEmitter = require('NativeEventEmitter'); const NativeModules = require('NativeModules'); const Platform = require('Platform'); const RCTNetInfo = NativeModules.NetInfo; -const deprecatedCallback = require('deprecatedCallback'); const NetInfoEventEmitter = new NativeEventEmitter(RCTNetInfo); @@ -257,12 +256,9 @@ const NetInfo = { }, }, - isConnectionExpensive(): Promise { - return deprecatedCallback( - Platform.OS === 'android' ? RCTNetInfo.isConnectionMetered() : Promise.reject(new Error('Currently not supported on iOS')), - Array.prototype.slice.call(arguments), - 'single-callback-value-first', - 'NetInfo.isConnectionMetered(callback) is deprecated. Use the returned Promise instead.' + isConnectionExpensive(): Promise { + return ( + Platform.OS === 'android' ? RCTNetInfo.isConnectionMetered() : Promise.reject(new Error('Currently not supported on iOS')) ); }, }; diff --git a/Libraries/Utilities/deprecatedCallback.js b/Libraries/Utilities/deprecatedCallback.js deleted file mode 100644 index ab180f66b11..00000000000 --- a/Libraries/Utilities/deprecatedCallback.js +++ /dev/null @@ -1,54 +0,0 @@ -/** - * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - * - * Helper for deprecated callback pattern - * - * @providesModule deprecatedCallback - * @flow - */ - -'use strict'; - -module.exports = function(promise: Promise, callbacks: Array, type: string, warning: string): Promise { - if (callbacks.length === 0) { - return promise; - } - - let success, error, callback; - - console.warn(warning); - - switch (type) { - case 'success-first': // handles func(success, error), func(success) - [ success, error ] = callbacks; - return promise.then( - res => success(res), - err => error && error(err) - ); - case 'error-first': // handles func(error, success) - [ error, success ] = callbacks; - return promise.then( - res => success(res), - err => error(err) - ); - case 'single-callback-value-first': // handles func(callback(value, err)) - [ callback ] = callbacks; - return promise.then( - res => callback(res), - err => callback(null, err) - ); - case 'node': // handles func(callback(err, value)) - [ callback ] = callbacks; - return promise.then( - res => callback(null, res), - err => callback(err) - ); - default: - throw new Error('Type of callbacks not specified. Must be one of \'success-first\', \'error-first\', \'single-callback-value-first\', or \'node\''); - } -}; diff --git a/Libraries/react-native/react-native.js b/Libraries/react-native/react-native.js index 0ac95193358..2ffdbb1b7d0 100644 --- a/Libraries/react-native/react-native.js +++ b/Libraries/react-native/react-native.js @@ -28,7 +28,6 @@ if (__DEV__) { const ReactNative = { // Components get ActivityIndicator() { return require('ActivityIndicator'); }, - get ActivityIndicatorIOS() { return require('ActivityIndicatorIOS'); }, get ART() { return require('ReactNativeART'); }, get Button() { return require('Button'); }, get DatePickerIOS() { return require('DatePickerIOS'); }, @@ -49,15 +48,12 @@ const ReactNative = { get ScrollView() { return require('ScrollView'); }, get SegmentedControlIOS() { return require('SegmentedControlIOS'); }, get Slider() { return require('Slider'); }, - get SliderIOS() { return require('SliderIOS'); }, get SnapshotViewIOS() { return require('SnapshotViewIOS'); }, get Switch() { return require('Switch'); }, get RecyclerViewBackedScrollView() { return require('RecyclerViewBackedScrollView'); }, get RefreshControl() { return require('RefreshControl'); }, get StatusBar() { return require('StatusBar'); }, get SwipeableListView() { return require('SwipeableListView'); }, - get SwitchAndroid() { return require('SwitchAndroid'); }, - get SwitchIOS() { return require('SwitchIOS'); }, get TabBarIOS() { return require('TabBarIOS'); }, get Text() { return require('Text'); }, get TextInput() { return require('TextInput'); }, @@ -80,7 +76,6 @@ const ReactNative = { get Animated() { return require('Animated'); }, get AppRegistry() { return require('AppRegistry'); }, get AppState() { return require('AppState'); }, - get AppStateIOS() { return require('AppStateIOS'); }, get AsyncStorage() { return require('AsyncStorage'); }, get BackAndroid() { return require('BackAndroid'); }, get CameraRoll() { return require('CameraRoll'); }, @@ -90,12 +85,10 @@ const ReactNative = { get Easing() { return require('Easing'); }, get I18nManager() { return require('I18nManager'); }, get ImagePickerIOS() { return require('ImagePickerIOS'); }, - get IntentAndroid() { return require('IntentAndroid'); }, get InteractionManager() { return require('InteractionManager'); }, get Keyboard() { return require('Keyboard'); }, get LayoutAnimation() { return require('LayoutAnimation'); }, get Linking() { return require('Linking'); }, - get LinkingIOS() { return require('LinkingIOS'); }, get NativeEventEmitter() { return require('NativeEventEmitter'); }, get NavigationExperimental() { return require('NavigationExperimental'); }, get NetInfo() { return require('NetInfo'); }, diff --git a/ReactAndroid/src/androidTest/js/TestIdTestModule.js b/ReactAndroid/src/androidTest/js/TestIdTestModule.js index 41b9b727222..7d1fbdf41e8 100644 --- a/ReactAndroid/src/androidTest/js/TestIdTestModule.js +++ b/ReactAndroid/src/androidTest/js/TestIdTestModule.js @@ -12,12 +12,12 @@ 'use strict'; var Image = require('Image'); +var Picker = require('Picker'); var ProgressBarAndroid = require('ProgressBarAndroid'); var React = require('React'); var ScrollView = require('ScrollView'); -var Picker = require('Picker'); var StyleSheet = require('StyleSheet'); -var SwitchAndroid = require('SwitchAndroid'); +var Switch = require('Switch'); var Text = require('Text'); var TextInput = require('TextInput'); var ToolbarAndroid = require('ToolbarAndroid'); @@ -83,7 +83,7 @@ class TestIdTestApp extends React.Component { - + text diff --git a/website/server/extractDocs.js b/website/server/extractDocs.js index b54f1f52078..c26fcc0512d 100644 --- a/website/server/extractDocs.js +++ b/website/server/extractDocs.js @@ -9,7 +9,6 @@ 'use strict'; -const assert = require('assert'); const babel = require('babel-core'); const deepAssign = require('deep-assign'); const docgen = require('react-docgen'); @@ -41,7 +40,7 @@ function getNameFromPath(filepath) { filepath = removeExtName(filepath); if (filepath === 'LayoutPropTypes') { return 'Layout Props'; - } else if (filepath == 'ShadowPropTypesIOS') { + } else if (filepath === 'ShadowPropTypesIOS') { return 'Shadow Props'; } else if (filepath === 'TransformPropTypes') { return 'Transforms'; @@ -65,7 +64,7 @@ function getPlatformFromPath(filepath) { function getExamplePaths(componentName, componentPlatform) { const componentExample = '../Examples/UIExplorer/js/' + componentName + 'Example.'; - let pathsToCheck = [ + const pathsToCheck = [ componentExample + 'js', componentExample + componentPlatform + '.js', ]; @@ -75,7 +74,7 @@ function getExamplePaths(componentName, componentPlatform) { componentExample + ANDROID_SUFFIX + '.js' ); } - let paths = []; + const paths = []; pathsToCheck.map((p) => { if (fs.existsSync(p)) { paths.push(p); @@ -87,7 +86,7 @@ function getExamplePaths(componentName, componentPlatform) { function getExamples(componentName, componentPlatform) { const paths = getExamplePaths(componentName, componentPlatform); if (paths) { - let examples = []; + const examples = []; paths.map((p) => { const platform = p.match(/Example\.(.*)\.js$/); let title = ''; @@ -243,7 +242,7 @@ function getTypedef(filepath, fileContent, json) { if (!json) { return typedefDocgen; } - let typedef = typedefDocgen; + const typedef = typedefDocgen; if (json.typedef && json.typedef.length !== 0) { json.typedef.forEach(def => { const typedefMatch = typedefDocgen.find(t => t.name === def.name); @@ -316,7 +315,7 @@ function parseAPIJsDocFormat(filepath, fileContent) { identifier.order = index; }); // Group by "kind" - let json = {}; + const json = {}; jsonParsed.forEach((identifier, index) => { let kind = identifier.kind; if (kind === 'function') { @@ -409,7 +408,7 @@ function getTypehint(typehint) { } function getJsDocFormatType(entities) { - let modEntities = entities; + const modEntities = entities; if (entities) { if (typeof entities === 'object' && entities.length) { entities.map((entity, entityIndex) => { @@ -440,11 +439,11 @@ function renderAPI(filepath, type) { const fileContent = fs.readFileSync(filepath).toString(); let json = parseAPIInferred(filepath, fileContent); if (isJsDocFormat(fileContent)) { - let jsonJsDoc = parseAPIJsDocFormat(filepath, fileContent); + const jsonJsDoc = parseAPIJsDocFormat(filepath, fileContent); // Combine method info with jsdoc formatted content const methods = json.methods; if (methods && methods.length) { - let modMethods = methods; + const modMethods = methods; methods.map((method, methodIndex) => { modMethods[methodIndex].params = getJsDocFormatType(method.params); modMethods[methodIndex].returns = @@ -486,7 +485,6 @@ function renderStyle(filepath) { const components = [ '../Libraries/Components/ActivityIndicator/ActivityIndicator.js', - '../Libraries/Components/ActivityIndicator/ActivityIndicatorIOS.ios.js', '../Libraries/Components/Button.js', '../Libraries/Components/DatePicker/DatePickerIOS.ios.js', '../Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js', @@ -505,12 +503,9 @@ const components = [ '../Libraries/Components/ScrollView/ScrollView.js', '../Libraries/Components/SegmentedControlIOS/SegmentedControlIOS.ios.js', '../Libraries/Components/Slider/Slider.js', - '../Libraries/Components/SliderIOS/SliderIOS.ios.js', '../Libraries/Components/StatusBar/StatusBar.js', '../Libraries/RCTTest/SnapshotViewIOS.ios.js', '../Libraries/Components/Switch/Switch.js', - '../Libraries/Components/SwitchAndroid/SwitchAndroid.android.js', - '../Libraries/Components/SwitchIOS/SwitchIOS.ios.js', '../Libraries/Components/TabBarIOS/TabBarIOS.ios.js', '../Libraries/Components/TabBarIOS/TabBarItemIOS.ios.js', '../Libraries/Text/Text.js', @@ -544,7 +539,6 @@ const apis = [ '../Libraries/Image/ImageEditor.js', '../Libraries/CameraRoll/ImagePickerIOS.js', '../Libraries/Image/ImageStore.js', - '../Libraries/Components/Intent/IntentAndroid.android.js', '../Libraries/Interaction/InteractionManager.js', '../Libraries/Components/Keyboard/Keyboard.js', '../Libraries/LayoutAnimation/LayoutAnimation.js',