I have implemented Flat List (Horizontal) in React Native. I have used onEndReached and onEndReachedThreshold to call an API. So when I scroll right a API gets called, but am not able to scroll left and call a different API on that, as my initial page number is '0' so won't be able to do left scroll.
So basically I need to set a page number for example as '3' so that i can scroll to left as well as right. And then my concern is how would I know that left scroll has been triggered or right to call different API's on both.
The things which I have implemented right now for right scroll is as below :
render() {
return (
<FlatList
horizontal
pagingEnabled
data={this.state.data}
renderItem={({ item }) => (
<View>
<Text> Details </Text>
<ScrollView>
<ListItem
title={item.name.first}
subtitle={item.email}
/>
<ListItem
title={item.name.last}
subtitle={item.email}
/>
<ListItem
title={item.address}
subtitle={item.email}
/>
</ScrollView>
</View>
)}
keyExtractor={item => item.email}
onRefresh={this.handleRefresh}
refreshing={this.state.refreshing}
onEndReached={this.handleRightLoadMore}
onEndReachedThreshold={10}
/>
);
}