expo / react-native-infinite-scroll-view

An infinitely scrolling view that notifies you as the scroll offset approaches the bottom
MIT License
519 stars 57 forks source link

loading icon on the bottom when loadMoreAsync works #38

Open TarekSalahUddinMahmud opened 7 years ago

TarekSalahUddinMahmud commented 7 years ago

I want to show loading icon on the bottom when loadMoreAsync works

Is it possible with this?

HugoCerdeiraSkrey commented 7 years ago

It should be simple, you can set a flag to true on your state at the beginning of the loadMoreAsync function, and to false when it reaches its end. In the render function if that flag is true you render the loading icon!

Hopefully, I helped, good luck!

dzpt commented 7 years ago

@HugoCerdeiraSkrey what's flag? I've tried to set this.state.isLoading = true but didn't see any loading indicator showed

dimaportenko commented 7 years ago

I'm using following <ListView dataSource={this.dataSource} renderRow={this.renderRow} renderScrollComponent={props => <InfiniteScrollView {...props} />} canLoadMore={this.props.canLoadMoreContent} onLoadMoreAsync={this.loadMoreContentAsync} />

loadMoreContentAsync is invoked, but I don't see any activity indicator. Am I doing something wrong?

hqtoan94 commented 6 years ago

@troublediehard I think you're right based on the document. But the problem might be because ListView won't render when your rowData is the same (at the end of the list, number of rows is the same until onLoadMoreAsync finish). That's what i think, i'm not sure about that also.

And my solution for that is:

So that we always have a child at the end of this.props.children and the Indicator will appear when the flag is true.

Here is my first solution, that might be a trick than a solution, but hope that helps somebody.