RCTRefreshControl icon indicating copy to clipboard operation
RCTRefreshControl copied to clipboard

Can a refresh be triggered with code?

Open syousif94 opened this issue 9 years ago • 3 comments

I'd like my list view to refresh on initial render to update stale cache. Is that possible?

syousif94 avatar Jun 19 '15 09:06 syousif94

Yes.

Sent from my iPhone

On Jun 19, 2015, at 5:45 PM, Sammy [email protected] wrote:

I'd like my list view to refresh on initial render to update stale cache. Is that possible?

— Reply to this email directly or view it on GitHub.

Shuangzuan avatar Jun 19 '15 10:06 Shuangzuan

I tried

var nodeHandle = React.findNodeHandle(this.refs.list);
NativeRCTRefreshControl.beginRefreshing(nodeHandle);

but it didn't work. Can you help me out?

syousif94 avatar Jun 20 '15 06:06 syousif94

@syousif94 could you get it working? beginRefreshing is not exported in js, so you need first to change the source adding to RCTRefreshControl.ios.js:

  beginRefreshing: function(node) {
    var nodeHandle = React.findNodeHandle(node);
    RefreshControl.beginRefreshing(nodeHandle);
  }

this way you can make the RefreshControl appear behind the ScrollView. Now, the problem is how to make the ScrollView showing it without manual scrolling. I tried to scrollTo the ScrollView, but it didn't work.

gpbl avatar Oct 10 '15 08:10 gpbl