react-native-gifted-listview icon indicating copy to clipboard operation
react-native-gifted-listview copied to clipboard

Is there a way to force a refresh?

Open benvium opened this issue 9 years ago • 9 comments

Great control by the way, thank you!

I would like to reload the data in the list manually. I've found the _refresh() method, which works quite nicely when I use it with this.refs.listView._refresh().

However, is there any way to stop the view scrolling up, showing the spinner, and scrolling down again? Perhaps an option?

benvium avatar Jan 29 '16 17:01 benvium

Hello @benvium, Maybe you can try

this.refs.listView._postRefresh(null, {external: true});

FaridSafi avatar Jan 29 '16 18:01 FaridSafi

Thanks Farid. Sadly that doesn't seem to have any effect at all. I'll stick with the _refresh() option for now.

benvium avatar Feb 01 '16 19:02 benvium

Hello guys, great library!

I just went through this situation, as mentioned by @benvium. In my case, I've tried a different approach, passing to the library a new prop called "shouldUpdate" (just to test), and testing this prop on "componentWillReceiveProps" lifecycle event. If this prop is true, I would run again onFetch.

  componentWillReceiveProps(nextProps) {
    if (nextProps.shouldUpdate) {
      this.props.onFetch(this._getPage(), this._postRefresh, {firstLoad: false});
    }
  },

What do you think about this approach? I would love to discuss it with you guys in order to have this refreshing working.

My use case: I have this listview showing comments. Above these, I have a place to insert a new comment. After submitting a new comment, I would like to refresh my listview in order to show this new comment.

Appreciate your feedback on it! Thanks

diegodurli avatar Feb 18 '16 03:02 diegodurli

@diegodurli It is worked for me but seems so slow to refresh. My use case: For searching.

WhatAKitty avatar Mar 28 '16 11:03 WhatAKitty

I use the 'private' function from the library: this.refs.listview._refresh(); My use case: For searching. It is worked very well.

LaryIII avatar Jun 13 '16 09:06 LaryIII

@LaryIII Could you please show some examples on how you use it for searching?

xzyaoi avatar Jul 22 '16 16:07 xzyaoi

doesn't work in my code , if there have another way? please , save my life @LaryIII @ @FaridSafi

FurshawFu avatar Mar 14 '17 04:03 FurshawFu

Can anyone please provide an example to refresh the gifted listview?

happy2share avatar Jul 22 '17 16:07 happy2share

@happy2share you can use FlatList in API , it can refresh & load more

zhaixiaoou avatar Aug 03 '17 11:08 zhaixiaoou