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?