Skip to content

Commit a71a9ef

Browse files
janicduplessisFacebook Github Bot 1
authored andcommitted
Remove deprecated PullToRefreshViewAndroid and onRefreshStart / endRefreshing
Summary: Removes the deprecated APIs that were replaced by `RefreshControl`. Those API have been deprecated for a while already so I think it's fine to remove them at this point. Also ported the `SwipeRefreshLayoutTestModule` test to use `RefreshControl` instead of `PullToRefreshViewAndroid`. **Test plan (required)** Made sure no references are left in the codebase to `PullToRefreshViewAndroid`, `onRefreshStart` and `endRefreshing`. Tested that `ScrollView` examples in UIExplorer still work properly. Check that the `SwipeRefreshLayoutTestModule` passes on CI. Closes facebook#7447 Reviewed By: mkonicek Differential Revision: D3292391 Pulled By: bestander fbshipit-source-id: 27eb2443861e04a9f7319586ce2ada381b714d47
1 parent 18d6d85 commit a71a9ef

File tree

9 files changed

+11
-203
lines changed

9 files changed

+11
-203
lines changed

Libraries/Components/ScrollView/ScrollView.js

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ const StyleSheetPropType = require('StyleSheetPropType');
2424
const View = require('View');
2525
const ViewStylePropTypes = require('ViewStylePropTypes');
2626

27-
const deprecatedPropType = require('deprecatedPropType');
2827
const dismissKeyboard = require('dismissKeyboard');
2928
const flattenStyle = require('flattenStyle');
3029
const invariant = require('fbjs/lib/invariant');
@@ -311,14 +310,6 @@ const ScrollView = React.createClass({
311310
*/
312311
refreshControl: PropTypes.element,
313312

314-
/**
315-
* @platform ios
316-
*/
317-
onRefreshStart: deprecatedPropType(
318-
PropTypes.func,
319-
'Use the `refreshControl` prop instead.'
320-
),
321-
322313
/**
323314
* Sometimes a scrollview takes up more space than its content fills. When this is
324315
* the case, this prop will fill the rest of the scrollview with a color to avoid setting
@@ -348,15 +339,6 @@ const ScrollView = React.createClass({
348339
this._scrollViewRef && this._scrollViewRef.setNativeProps(props);
349340
},
350341

351-
/**
352-
* Deprecated. Use `RefreshControl` instead.
353-
*/
354-
endRefreshing: function() {
355-
RCTScrollViewManager.endRefreshing(
356-
ReactNative.findNodeHandle(this)
357-
);
358-
},
359-
360342
/**
361343
* Returns a reference to the underlying scroll responder, which supports
362344
* operations like `scrollTo`. All ScrollView-like components should
@@ -510,14 +492,6 @@ const ScrollView = React.createClass({
510492
sendMomentumEvents: (this.props.onMomentumScrollBegin || this.props.onMomentumScrollEnd) ? true : false,
511493
};
512494

513-
const onRefreshStart = this.props.onRefreshStart;
514-
if (onRefreshStart) {
515-
// this is necessary because if we set it on props, even when empty,
516-
// it'll trigger the default pull-to-refresh behavior on native.
517-
props.onRefreshStart =
518-
function() { onRefreshStart && onRefreshStart(this.endRefreshing); }.bind(this);
519-
}
520-
521495
const { decelerationRate } = this.props;
522496
if (decelerationRate) {
523497
props.decelerationRate = processDecelerationRate(decelerationRate);

Libraries/PullToRefresh/PullToRefreshViewAndroid.android.js

Lines changed: 0 additions & 107 deletions
This file was deleted.

Libraries/PullToRefresh/PullToRefreshViewAndroid.ios.js

Lines changed: 0 additions & 13 deletions
This file was deleted.

Libraries/react-native/react-native.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ var ReactNative = {
4949
get SliderIOS() { return require('SliderIOS'); },
5050
get SnapshotViewIOS() { return require('SnapshotViewIOS'); },
5151
get Switch() { return require('Switch'); },
52-
get PullToRefreshViewAndroid() { return require('PullToRefreshViewAndroid'); },
5352
get RecyclerViewBackedScrollView() { return require('RecyclerViewBackedScrollView'); },
5453
get RefreshControl() { return require('RefreshControl'); },
5554
get StatusBar() { return require('StatusBar'); },

Libraries/react-native/react-native.js.flow

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ var ReactNative = Object.assign(Object.create(require('ReactNative')), {
4848
SnapshotViewIOS: require('SnapshotViewIOS'),
4949
StatusBar: require('StatusBar'),
5050
Switch: require('Switch'),
51-
PullToRefreshViewAndroid: require('PullToRefreshViewAndroid'),
5251
RecyclerViewBackedScrollView: require('RecyclerViewBackedScrollView'),
5352
RefreshControl: require('RefreshControl'),
5453
SwitchAndroid: require('SwitchAndroid'),

React/Views/RCTScrollView.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,6 @@
5858
@property (nonatomic, copy) RCTDirectEventBlock onMomentumScrollEnd;
5959
@property (nonatomic, copy) RCTDirectEventBlock onScrollAnimationEnd;
6060

61-
// Pull-to-refresh support (deprecated - use RCTPullToRefreshControl instead)
62-
@property (nonatomic, copy) RCTDirectEventBlock onRefreshStart;
63-
- (void)endRefreshing;
64-
6561
@end
6662

6763
@interface RCTEventDispatcher (RCTScrollView)

React/Views/RCTScrollView.m

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -934,34 +934,6 @@ - (type)getter \
934934
RCT_SET_AND_PRESERVE_OFFSET(setZoomScale, zoomScale, CGFloat);
935935
RCT_SET_AND_PRESERVE_OFFSET(setScrollIndicatorInsets, scrollIndicatorInsets, UIEdgeInsets);
936936

937-
- (void)setOnRefreshStart:(RCTDirectEventBlock)onRefreshStart
938-
{
939-
if (!onRefreshStart) {
940-
_onRefreshStart = nil;
941-
_scrollView.refreshControl = nil;
942-
return;
943-
}
944-
_onRefreshStart = [onRefreshStart copy];
945-
946-
if (!_scrollView.refreshControl) {
947-
RCTRefreshControl *refreshControl = [RCTRefreshControl new];
948-
[refreshControl addTarget:self action:@selector(refreshControlValueChanged) forControlEvents:UIControlEventValueChanged];
949-
_scrollView.refreshControl = refreshControl;
950-
}
951-
}
952-
953-
- (void)refreshControlValueChanged
954-
{
955-
if (self.onRefreshStart) {
956-
self.onRefreshStart(nil);
957-
}
958-
}
959-
960-
- (void)endRefreshing
961-
{
962-
[_scrollView.refreshControl endRefreshing];
963-
}
964-
965937
- (void)sendScrollEventWithName:(NSString *)eventName
966938
scrollView:(UIScrollView *)scrollView
967939
userData:(NSDictionary *)userData

React/Views/RCTScrollViewManager.m

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ - (UIView *)view
7272
RCT_EXPORT_VIEW_PROPERTY(snapToInterval, int)
7373
RCT_EXPORT_VIEW_PROPERTY(snapToAlignment, NSString)
7474
RCT_REMAP_VIEW_PROPERTY(contentOffset, scrollView.contentOffset, CGPoint)
75-
RCT_EXPORT_VIEW_PROPERTY(onRefreshStart, RCTDirectEventBlock)
7675
RCT_EXPORT_VIEW_PROPERTY(onScrollBeginDrag, RCTDirectEventBlock)
7776
RCT_EXPORT_VIEW_PROPERTY(onScroll, RCTDirectEventBlock)
7877
RCT_EXPORT_VIEW_PROPERTY(onScrollEndDrag, RCTDirectEventBlock)
@@ -119,21 +118,6 @@ - (UIView *)view
119118
}];
120119
}
121120

122-
RCT_EXPORT_METHOD(endRefreshing:(nonnull NSNumber *)reactTag)
123-
{
124-
[self.bridge.uiManager addUIBlock:
125-
^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, RCTScrollView *> *viewRegistry) {
126-
127-
RCTScrollView *view = viewRegistry[reactTag];
128-
if (!view || ![view isKindOfClass:[RCTScrollView class]]) {
129-
RCTLogError(@"Cannot find RCTScrollView with tag #%@", reactTag);
130-
return;
131-
}
132-
133-
[view endRefreshing];
134-
}];
135-
}
136-
137121
RCT_EXPORT_METHOD(scrollTo:(nonnull NSNumber *)reactTag
138122
offsetX:(CGFloat)x
139123
offsetY:(CGFloat)y

ReactAndroid/src/androidTest/js/SwipeRefreshLayoutTestModule.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ var BatchedBridge = require('BatchedBridge');
1515
var React = require('React');
1616
var RecordingModule = require('NativeModules').SwipeRefreshLayoutRecordingModule;
1717
var ScrollView = require('ScrollView');
18-
var PullToRefreshViewAndroid = require('PullToRefreshViewAndroid');
18+
var RefreshControl = require('RefreshControl');
1919
var Text = require('Text');
2020
var TouchableWithoutFeedback = require('TouchableWithoutFeedback');
2121
var View = require('View');
@@ -62,13 +62,17 @@ var SwipeRefreshLayoutTestApp = React.createClass({
6262
rows.push(<Row key={i} />);
6363
}
6464
return (
65-
<PullToRefreshViewAndroid
65+
<ScrollView
6666
style={{flex: 1}}
67-
onRefresh={() => RecordingModule.onRefresh()}>
68-
<ScrollView style={{flex: 1}}>
69-
{rows}
70-
</ScrollView>
71-
</PullToRefreshViewAndroid>
67+
refreshControl={
68+
<RefreshControl
69+
style={{flex: 1}}
70+
refreshing={false}
71+
onRefresh={() => RecordingModule.onRefresh()}
72+
/>
73+
}>
74+
{rows}
75+
</ScrollView>
7276
);
7377
},
7478
});

0 commit comments

Comments
 (0)