0

I need to do some actions when the user has finished refreshing the data on my FlatList with onRefresh props.

I didn't find anything on the doc, so I was wondering if there was any way to do something like that?

Viktor Jovanovic
  • 491
  • 5
  • 15
  • what is mean refreshing the data? scrolling to end? coming new data to the list? – Idan Aug 15 '19 at 21:39
  • When user refreshing FlatList with onRefresh props (pull to refresh), I need to refresh my redux store and after that, call my API to get new informations. So I am looking for a solution so that when my onRefresh is finished, I can execute a function. Like an onRefreshOver or something like that. I'm not sure it's clear – Viktor Jovanovic Aug 15 '19 at 21:49
  • Do you mean blocking the pull refresh when there is no new data from now on? – Auticcat Aug 15 '19 at 22:05
  • Ok i get you, please share your code – Idan Aug 16 '19 at 07:52
  • [this is my code](https://pastebin.com/BzEkHj7W) @idan so I want to reset my store redux list during the onRefresh and when onRefresh is over, I want to fetch my new data. I heard about thunk redux but I'm completely lost with that, so this is the reason why I'm looking for an alternative solution like 'onRefreshOver' – Viktor Jovanovic Aug 16 '19 at 11:04
  • I don't know if there is something like that because the list loading lazy so when it starts to show items it's not the time that list end to loading, maybe try to do something with `onEndReached` property – Idan Aug 16 '19 at 13:28
  • Oh yes, you right! It seems completely logical! I'll check with onEndReached! Thanks – Viktor Jovanovic Aug 16 '19 at 15:09

1 Answers1

1

Maybe you are looking for something like this https://medium.com/@pateldhara248/flatlist-with-loadmore-and-pull-to-refresh-582d48eca60b. It says that you need to provide refreshControl prop to FlatList which will be your Component displayed when the flatList is pulled to refresh. and to this component you will provide prop onRefresh which will be a function called when the Flatlist is pulled to refresh so in that function you can call your API to fetch data for the FlatList.

Waheed Akhter
  • 347
  • 2
  • 13