From 91788d2bbd35a530269664c71cd17220cc7bc80a Mon Sep 17 00:00:00 2001 From: Janic Duplessis Date: Sun, 21 Feb 2016 16:16:42 -0800 Subject: [PATCH] Deprecate PullToRefreshViewAndroid and remove it from the website Summary:I forgot to add a deprecation warning to PullToRefreshViewAndroid when I worked on RefreshControl. This adds one as well as remove it from the website and remove the UIExplorer example. Now that we have versioned doc I think it is fine to remove deprecated stuff from the website so it is easier for users to know what component they should use. Last thing, I enabled flow in RefreshControl and fixed the one warning. Closes https://github.com/facebook/react-native/pull/6055 Differential Revision: D2959502 Pulled By: mkonicek fb-gh-sync-id: 9b23f84ea35c770bfe2a83d0fd3ec7e439669c33 shipit-source-id: 9b23f84ea35c770bfe2a83d0fd3ec7e439669c33 --- ...PullToRefreshViewAndroidExample.android.js | 128 ------------------ Examples/UIExplorer/UIExplorerList.android.js | 1 - .../RefreshControl/RefreshControl.js | 7 +- .../PullToRefreshViewAndroid.android.js | 8 +- website/server/extractDocs.js | 1 - 5 files changed, 11 insertions(+), 134 deletions(-) delete mode 100644 Examples/UIExplorer/PullToRefreshViewAndroidExample.android.js diff --git a/Examples/UIExplorer/PullToRefreshViewAndroidExample.android.js b/Examples/UIExplorer/PullToRefreshViewAndroidExample.android.js deleted file mode 100644 index 3d22f7608e93f9..00000000000000 --- a/Examples/UIExplorer/PullToRefreshViewAndroidExample.android.js +++ /dev/null @@ -1,128 +0,0 @@ -/** -* The examples provided by Facebook are for non-commercial testing and -* evaluation purposes only. -* -* Facebook reserves all rights not expressly granted. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL -* FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -* -*/ -'use strict'; - -const React = require('react-native'); -const { - ScrollView, - StyleSheet, - PullToRefreshViewAndroid, - Text, - TouchableWithoutFeedback, - View, -} = React; - -const styles = StyleSheet.create({ - row: { - borderColor: 'grey', - borderWidth: 1, - padding: 20, - backgroundColor: '#3a5795', - margin: 5, - }, - text: { - alignSelf: 'center', - color: '#fff', - - }, - layout: { - flex: 1, - }, - scrollview: { - flex: 1, - }, -}); - -const Row = React.createClass({ - _onClick: function() { - this.props.onClick(this.props.data); - }, - render: function() { - return ( - - - - {this.props.data.text + ' (' + this.props.data.clicks + ' clicks)'} - - - - ); - }, -}); -const PullToRefreshViewAndroidExample = React.createClass({ - statics: { - title: '', - description: 'Container that adds pull-to-refresh support to its child view.' - }, - - getInitialState() { - return { - isRefreshing: false, - loaded: 0, - rowData: Array.from(new Array(20)).map( - (val, i) => ({text: 'Initial row' + i, clicks: 0}) - ), - }; - }, - - _onClick(row) { - row.clicks++; - this.setState({ - rowData: this.state.rowData, - }); - }, - - render() { - const rows = this.state.rowData.map((row, ii) => { - return ; - }); - return ( - - - {rows} - - - ); - }, - - _onRefresh() { - this.setState({isRefreshing: true}); - setTimeout(() => { - // prepend 10 items - const rowData = Array.from(new Array(10)) - .map((val, i) => ({ - text: 'Loaded row' + (+this.state.loaded + i), - clicks: 0, - })) - .concat(this.state.rowData); - - this.setState({ - loaded: this.state.loaded + 10, - isRefreshing: false, - rowData: rowData, - }); - }, 5000); - }, - -}); - - -module.exports = PullToRefreshViewAndroidExample; diff --git a/Examples/UIExplorer/UIExplorerList.android.js b/Examples/UIExplorer/UIExplorerList.android.js index 8959a0919f9a63..4cd5649d706668 100644 --- a/Examples/UIExplorer/UIExplorerList.android.js +++ b/Examples/UIExplorer/UIExplorerList.android.js @@ -27,7 +27,6 @@ var COMPONENTS = [ require('./ListViewExample'), require('./PickerAndroidExample'), require('./ProgressBarAndroidExample'), - require('./PullToRefreshViewAndroidExample.android'), require('./RefreshControlExample'), require('./ScrollViewSimpleExample'), require('./StatusBarExample'), diff --git a/Libraries/Components/RefreshControl/RefreshControl.js b/Libraries/Components/RefreshControl/RefreshControl.js index 1ae8119a1e2e0f..ee285a3c752bee 100644 --- a/Libraries/Components/RefreshControl/RefreshControl.js +++ b/Libraries/Components/RefreshControl/RefreshControl.js @@ -7,6 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. * * @providesModule RefreshControl + * @flow */ 'use strict'; @@ -17,10 +18,10 @@ const View = require('View'); const requireNativeComponent = require('requireNativeComponent'); -if (Platform.OS === 'ios') { - var RefreshLayoutConsts = {SIZE: {}}; -} else if (Platform.OS === 'android') { +if (Platform.OS === 'android') { var RefreshLayoutConsts = require('NativeModules').UIManager.AndroidSwipeRefreshLayout.Constants; +} else { + var RefreshLayoutConsts = {SIZE: {}}; } /** diff --git a/Libraries/PullToRefresh/PullToRefreshViewAndroid.android.js b/Libraries/PullToRefresh/PullToRefreshViewAndroid.android.js index c0f498ba253266..e784052c3960a0 100644 --- a/Libraries/PullToRefresh/PullToRefreshViewAndroid.android.js +++ b/Libraries/PullToRefresh/PullToRefreshViewAndroid.android.js @@ -21,9 +21,11 @@ var requireNativeComponent = require('requireNativeComponent'); var NATIVE_REF = 'native_swiperefreshlayout'; /** + * Deprecated. Use `RefreshControl` instead. + * * React view that supports a single scrollable child view (e.g. `ScrollView`). When this child * view is at `scrollY: 0`, swiping down triggers an `onRefresh` event. - * + * * The style `{flex: 1}` might be required to ensure the expected behavior of the child component * (e.g. when the child is expected to scroll with `ScrollView` or `ListView`). */ @@ -56,6 +58,10 @@ var PullToRefreshViewAndroid = React.createClass({ size: React.PropTypes.oneOf(RefreshLayoutConsts.SIZE.DEFAULT, RefreshLayoutConsts.SIZE.LARGE), }, + componentDidMount: function() { + console.warn('`PullToRefreshViewAndroid` is deprecated. Use `RefreshControl` instead.'); + }, + getInnerViewNode: function() { return this.refs[NATIVE_REF]; }, diff --git a/website/server/extractDocs.js b/website/server/extractDocs.js index 8fd0992314cbb5..b74c029b76c0e5 100644 --- a/website/server/extractDocs.js +++ b/website/server/extractDocs.js @@ -203,7 +203,6 @@ var components = [ '../Libraries/Components/Picker/Picker.js', '../Libraries/Components/ProgressBarAndroid/ProgressBarAndroid.android.js', '../Libraries/Components/ProgressViewIOS/ProgressViewIOS.ios.js', - '../Libraries/PullToRefresh/PullToRefreshViewAndroid.android.js', '../Libraries/Components/RefreshControl/RefreshControl.js', '../Libraries/Components/ScrollView/ScrollView.js', '../Libraries/Components/SegmentedControlIOS/SegmentedControlIOS.ios.js',