react-native-infinite-scroll-view
Advanced tools
Comparing version
module.exports = { | ||
extends: 'expo/react', | ||
rules: { | ||
'comma-dangle': [0], | ||
'operator-linebreak': [0], | ||
extends: 'universe/native', | ||
settings: { | ||
react: { | ||
version: '16', | ||
}, | ||
}, | ||
}; |
'use strict'; | ||
import React from 'react'; | ||
import { | ||
ActivityIndicator, | ||
StyleSheet, | ||
View, | ||
} from 'react-native'; | ||
import { ActivityIndicator, StyleSheet, View } from 'react-native'; | ||
@@ -10,0 +6,0 @@ export default class DefaultLoadingIndicator extends React.Component { |
@@ -5,6 +5,3 @@ 'use strict'; | ||
import React from 'react'; | ||
import { | ||
ScrollView, | ||
View, | ||
} from 'react-native'; | ||
import { ScrollView, View } from 'react-native'; | ||
import ScrollableMixin from 'react-native-scrollable-mixin'; | ||
@@ -20,6 +17,3 @@ | ||
distanceToLoadMore: PropTypes.number.isRequired, | ||
canLoadMore: PropTypes.oneOfType([ | ||
PropTypes.func, | ||
PropTypes.bool, | ||
]).isRequired, | ||
canLoadMore: PropTypes.oneOfType([PropTypes.func, PropTypes.bool]).isRequired, | ||
onLoadMoreAsync: PropTypes.func.isRequired, | ||
@@ -64,18 +58,12 @@ onLoadError: PropTypes.func, | ||
statusIndicator = React.cloneElement( | ||
this.props.renderLoadingErrorIndicator( | ||
{ onRetryLoadMore: this._loadMoreAsync } | ||
), | ||
{ key: 'loading-error-indicator' }, | ||
this.props.renderLoadingErrorIndicator({ onRetryLoadMore: this._loadMoreAsync }), | ||
{ key: 'loading-error-indicator' } | ||
); | ||
} else if (this.state.isLoading) { | ||
statusIndicator = React.cloneElement( | ||
this.props.renderLoadingIndicator(), | ||
{ key: 'loading-indicator' }, | ||
); | ||
statusIndicator = React.cloneElement(this.props.renderLoadingIndicator(), { | ||
key: 'loading-indicator', | ||
}); | ||
} | ||
let { | ||
renderScrollComponent, | ||
...props, | ||
} = this.props; | ||
let { renderScrollComponent, ...props } = this.props; | ||
Object.assign(props, { | ||
@@ -87,3 +75,5 @@ onScroll: this._handleScroll, | ||
return cloneReferencedElement(renderScrollComponent(props), { | ||
ref: component => { this._scrollComponent = component; }, | ||
ref: component => { | ||
this._scrollComponent = component; | ||
}, | ||
}); | ||
@@ -105,10 +95,13 @@ } | ||
_shouldLoadMore(event) { | ||
let canLoadMore = (typeof this.props.canLoadMore === 'function') ? | ||
this.props.canLoadMore() : | ||
this.props.canLoadMore; | ||
let canLoadMore = | ||
typeof this.props.canLoadMore === 'function' | ||
? this.props.canLoadMore() | ||
: this.props.canLoadMore; | ||
return !this.state.isLoading && | ||
return ( | ||
!this.state.isLoading && | ||
canLoadMore && | ||
!this.state.isDisplayingError && | ||
this._distanceFromEnd(event) < this.props.distanceToLoadMore; | ||
this._distanceFromEnd(event) < this.props.distanceToLoadMore | ||
); | ||
} | ||
@@ -122,3 +115,3 @@ | ||
try { | ||
this.setState({isDisplayingError: false, isLoading: true}); | ||
this.setState({ isDisplayingError: false, isLoading: true }); | ||
await this.props.onLoadMoreAsync(); | ||
@@ -129,15 +122,10 @@ } catch (e) { | ||
} | ||
this.setState({isDisplayingError: true}); | ||
this.setState({ isDisplayingError: true }); | ||
} finally { | ||
this.setState({isLoading: false}); | ||
this.setState({ isLoading: false }); | ||
} | ||
} | ||
_distanceFromEnd(event): number { | ||
let { | ||
contentSize, | ||
contentInset, | ||
contentOffset, | ||
layoutMeasurement, | ||
} = event.nativeEvent; | ||
_distanceFromEnd(event) { | ||
let { contentSize, contentInset, contentOffset, layoutMeasurement } = event.nativeEvent; | ||
@@ -144,0 +132,0 @@ let contentLength; |
{ | ||
"name": "react-native-infinite-scroll-view", | ||
"version": "0.4.3", | ||
"version": "0.4.5", | ||
"description": "An infinitely scrolling view that notifies you as the scroll offset approaches the bottom", | ||
"main": "InfiniteScrollView.js", | ||
"scripts": { | ||
"lint": "eslint .", | ||
"test": "eslint ." | ||
"lint": "eslint ." | ||
}, | ||
@@ -20,3 +19,3 @@ "repository": { | ||
], | ||
"author": "James Ide <ide@expo.io>", | ||
"author": "Expo", | ||
"license": "MIT", | ||
@@ -28,3 +27,3 @@ "bugs": { | ||
"dependencies": { | ||
"prop-types": "^15.5.10", | ||
"prop-types": "^15.6.2", | ||
"react-clone-referenced-element": "^1.0.1", | ||
@@ -34,10 +33,6 @@ "react-native-scrollable-mixin": "^1.0.0" | ||
"devDependencies": { | ||
"babel-eslint": "^7.1.1", | ||
"eslint": "^3.12.2", | ||
"eslint-config-expo": "^5.1.3", | ||
"eslint-plugin-babel": "^4.0.0", | ||
"eslint-plugin-flowtype": "^2.29.2", | ||
"eslint-plugin-import": "^2.2.0", | ||
"eslint-plugin-react": "^6.8.0" | ||
"eslint": "^5.4.0", | ||
"eslint-config-universe": "^2.0.0-alpha.0", | ||
"prettier": "^1.14.2" | ||
} | ||
} |
@@ -1,6 +0,6 @@ | ||
# InfiniteScrollView [](http://slack.exponentjs.com) | ||
# InfiniteScrollView [](https://circleci.com/gh/expo/react-native-infinite-scroll-view) | ||
InfiniteScrollView is a React Native scroll view that notifies you as the scroll offset approaches the bottom. You can instruct it to display a loading indicator while you load more content. This is a common design in feeds. InfiniteScrollView also supports horizontal scroll views. | ||
It conforms to [ScrollableMixin](https://github.com/exponentjs/react-native-scrollable-mixin) so you can compose it with other scrollable components. | ||
It conforms to [ScrollableMixin](https://github.com/expo/react-native-scrollable-mixin) so you can compose it with other scrollable components. | ||
@@ -154,3 +154,3 @@ [](https://nodei.co/npm/react-native-infinite-scroll-view/) | ||
- When you load more content in an infinite ListView, the ListView by default will render only one row per frame. This means that for a short amount of time after loading new content, the user could still be very close to the bottom of the scroll view and may trigger a second load. | ||
- Known issue: Make sure your initial data reaches the bottom of the screen, otherwise scroll events won't trigger. Subsequent loads are not affected. See [exponentjs/react-native-infinite-scroll-view#9](https://github.com/exponentjs/react-native-infinite-scroll-view/issues/9) for more details. | ||
- Known issue: Make sure your initial data reaches the bottom of the screen, otherwise scroll events won't trigger. Subsequent loads are not affected. See [expo/react-native-infinite-scroll-view#9](https://github.com/expo/react-native-infinite-scroll-view/issues/9) for more details. | ||
@@ -157,0 +157,0 @@ ## Implementation |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
55756
6.45%3
-57.14%8
-11.11%150
-9.09%Updated