mirror of
https://github.com/status-im/react-native.git
synced 2025-02-26 08:05:34 +00:00
Add custom RefreshControl support to VirtualizedList
Reviewed By: TheSavior, mmmulani Differential Revision: D7388137 fbshipit-source-id: 8a1448e5fc526b45773fe4a4f123a179d4a8bee9
This commit is contained in:
parent
f96d7ae648
commit
fd4bc72512
@ -173,6 +173,12 @@ type OptionalProps = {
|
||||
* @platform android
|
||||
*/
|
||||
progressViewOffset?: number,
|
||||
/**
|
||||
* A custom refresh control element. When set, it overrides the default
|
||||
* <RefreshControl> component built internally. The onRefresh and refreshing
|
||||
* props are also ignored. Only works for vertical VirtualizedList.
|
||||
*/
|
||||
refreshControl?: ?React.Element<any>,
|
||||
/**
|
||||
* Set this true while waiting for new data from a refresh.
|
||||
*/
|
||||
@ -893,9 +899,10 @@ class VirtualizedList extends React.PureComponent<Props, State> {
|
||||
onScrollEndDrag: this._onScrollEndDrag,
|
||||
onMomentumScrollEnd: this._onMomentumScrollEnd,
|
||||
scrollEventThrottle: this.props.scrollEventThrottle, // TODO: Android support
|
||||
invertStickyHeaders: this.props.invertStickyHeaders !== undefined
|
||||
? this.props.invertStickyHeaders
|
||||
: this.props.inverted,
|
||||
invertStickyHeaders:
|
||||
this.props.invertStickyHeaders !== undefined
|
||||
? this.props.invertStickyHeaders
|
||||
: this.props.inverted,
|
||||
stickyHeaderIndices,
|
||||
};
|
||||
if (inversionStyle) {
|
||||
@ -990,9 +997,10 @@ class VirtualizedList extends React.PureComponent<Props, State> {
|
||||
}
|
||||
|
||||
_defaultRenderScrollComponent = props => {
|
||||
const onRefresh = props.onRefresh;
|
||||
if (this._isNestedWithSameOrientation()) {
|
||||
return <View {...props} />;
|
||||
} else if (props.onRefresh) {
|
||||
} else if (onRefresh) {
|
||||
invariant(
|
||||
typeof props.refreshing === 'boolean',
|
||||
'`refreshing` prop must be set as a boolean in order to use `onRefresh`, but got `' +
|
||||
@ -1003,14 +1011,15 @@ class VirtualizedList extends React.PureComponent<Props, State> {
|
||||
<ScrollView
|
||||
{...props}
|
||||
refreshControl={
|
||||
/* $FlowFixMe(>=0.53.0 site=react_native_fb,react_native_oss) This
|
||||
* comment suppresses an error when upgrading Flow's support for
|
||||
* React. To see the error delete this comment and run Flow. */
|
||||
<RefreshControl
|
||||
refreshing={props.refreshing}
|
||||
onRefresh={props.onRefresh}
|
||||
progressViewOffset={props.progressViewOffset}
|
||||
/>
|
||||
props.refreshControl == null ? (
|
||||
<RefreshControl
|
||||
refreshing={props.refreshing}
|
||||
onRefresh={onRefresh}
|
||||
progressViewOffset={props.progressViewOffset}
|
||||
/>
|
||||
) : (
|
||||
props.refreshControl
|
||||
)
|
||||
}
|
||||
/>
|
||||
);
|
||||
|
Loading…
x
Reference in New Issue
Block a user