Deprecated. A pull-to-refresh ListView which shows a loading spinner while your data reloads
Deprecated. A pull-to-refresh ListView which shows a loading spinner while your data reloads
A pull-to-refresh ListView which shows a loading spinner while your data reloads
Deprecated: now you can use the built-in RefreshControl instead.
In action (from ReactNativeHackerNews):
Note: these are the docs for the 2.x branch, currently in beta. If you are looking for the docs for a 1.x version, see the 1.x branch.
You can install the latest beta with npm install react-native-refreshable-listview@next
Replace a ListView with a RefreshableListView to add pulldown-to-refresh functionality. Accepts the same props as ListView, plus a few extras (see the props definitions below).
…
loadData: func.isRequired
A function returning a Promise or taking a callback, invoked upon pulldown.
The refreshing indicator (spinner) will show until the Promise resolves or the callback
is called.refreshDescription: oneOfType([string, element])
Text/element to show alongside spinner. If a custom
refreshingIndicatorComponent is used this value will be passed as its
description prop.refreshingIndicatorComponent: oneOfType([func, element])
Content to show in list header when refreshing. Can be a component class or
instantiated element. Defaults to RefreshableListView.RefreshingIndicator.
You can easily customise the appearance of the indicator by passing in a
customised <RefreshableListView.RefreshingIndicator />, or provide your own
entirely custom content to be displayed.minDisplayTime: number
Minimum time the spinner will show for.minBetweenTime: number
Minimum time after a refresh before another refresh can be performed.minPulldownDistance: number
Minimum distance (in px) which the list has to be scrolled off the top to
trigger a refresh.ignoreInertialScroll: bool
Require the user to be actually touching the screen when the pulldown distance
exceeds minPulldownDistance to trigger a refresh (eg. not just inertially
scrolling off the top). Defaults to true.onScroll: func
An event handler for the onScroll event which will be chained after the one
defined by the RefreshableListView.scrollEventThrottle: number
How often ListView produces scroll events, in ms. Defaults to a fairly low
value, try setting it higher if you encounter performance issues. Keep in mind
that a higher value will make the pulldown-to-refresh behaviour less responsive.colors: array of strings
Colors to be used for pull to refresh indicator in AndroidprogressBackgroundColor: string
Color to be used for pull to refresh indicator background in AndroidLow level component used by RefreshableListView. Use this directly if you want
to manually control the refreshing status (rather than using a Promise).
This component is more suitable for use in a Redux-style connected component.
…
onRefresh: func.isRequired
Called when user pulls listview down to refresh.isRefreshing: bool.isRequired
Whether or not to show the refreshing indicator.refreshDescription: oneOfType([string, element])
See RefreshableListViewrefreshingIndicatorComponent: oneOfType([func, element])
See RefreshableListViewminPulldownDistance: number
See RefreshableListViewignoreInertialScroll: bool
See RefreshableListViewonScroll: func
See RefreshableListViewscrollEventThrottle: number
See RefreshableListViewComponent with activity indicator to be displayed in list header when refreshing.
(also exposed as ControlledRefreshableListView.RefreshingIndicator)
description: oneOfType([string, element])
Text/element to show alongside spinner.stylesheet: object
A stylesheet object which overrides one or more of the styles defined in the
RefreshingIndicator stylesheet.activityIndicatorComponent: oneOfType([func, element])
The spinner to display. Defaults to <ActivityIndicatorIOS />.Aliases of ListView.DataSource, for convenience.
Your first option is to style the default RefreshingIndicator:
var indicatorStylesheet = StyleSheet.create({
wrapper: {
backgroundColor: 'red',
height: 60,
marginTop: 10,
},
content: {
backgroundColor: 'blue',
marginTop: 10,
height: 60,
},
})
<RefreshableListView
refreshingIndicatorComponent={
<RefreshableListView.RefreshingIndicator stylesheet={indicatorStylesheet} />
}
/>
Alternatively, you can provide a custom RefreshingIndicator:
var MyRefreshingIndicator = React.createClass({
render() {
return (
<View>
<MySpinner />
<Text>{this.props.description}</Text>
</View>
)
},
})
<RefreshableListView refreshingIndicatorComponent={MyRefreshingIndicator} />
// or
<RefreshableListView refreshingIndicatorComponent={<MyRefreshingIndicator />} />
2.0.0-beta4
2.0.0-beta3
2.0.0-beta2
renderHeaderWrapper is no longer used 1.2.0
renderHeader in favour of renderHeaderWrapper as some
developers seemed to be confused by the fact that a renderHeader handler
for a standard ListView will not automatically just work with this component,
but rather needs to be modified as described in the documentation. The new prop
renderHeaderWrapper works identically to the previous one, however hopefully
now it is named differently it will be more apparent that its behaviour is not
the same as with ListView. The renderHeader prop will be removed in 2.0.1.1.0
1.0.0
0.3.0 added minPulldownTime & minBetweenTime props, fixed bug where refresh could happen twice
0.2.0 added support for ListView props setNativeProps and getScrollResponder (@almost & @sscotth)
No open issues yet, or sync has not completed.