I'm making a "todo" view for a calendar application. When you scroll down to the end of the list, it grabs upcoming events from the server and puts them at the bottom of the list. This is simple with react native. However, I would also like to allow the user to scroll up to view earlier dates and events. When they scroll to the top of the list, load earlier items. Unfortunately, there is no equivalent to onEndReached
, but for the start. Any ideas/guidance on the best way to handle this?
Could you not use the ScrollView
onScroll
callback. The event argument gives you the scroll position. When the value is tending back towards 0, you can load more items and prepend them.
To do this you'd likely need to persist the previous value for comparison to determine the direction of scroll.
Also see this question: React native: get current scroll position of scrollview
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With