javascript
Fetch Data at the end of ScrollView
const isCloseToBottom = ({ layoutMeasurement, contentOffset, contentSize }) => {
const paddingToBottom = 50;
return (
layoutMeasurement.height + contentOffset.y >=
contentSize.height - paddingToBottom
);
};
<ScrollView
style={styles.content}
showsVerticalScrollIndicator={false}
onScroll={({ nativeEvent }) => {
if (isCloseToBottom(nativeEvent) && explore.length % 2 === 0) {
fetchData();
}
}}>
</ScrollView>
Was this helpful?
Similar Posts
- Javascript fetch
- Remove new line separator from start and end positions of string in Javascript
- Lodash - Find item index from array by searching from the end
- Batched Requests - AirTable - Automations - Front End - 12/3/21
- Sort Tree - Bloomberg - Port Interactive Analytics - Front End - 12/6/21
- Create form data in Javascript
- xhr post request with form data javascript
- Convert String to JSON Data