8

I have a scrollview which content is larger than phone screen.
I scroll to the bottom and there I have function that reload content of that scrollview but first clear data source for it.
Reload function is connected to RefreshControl on scrollview.
But RefreshControl is not visible while loading data except when I slightly touch screen where content should be.
And this is only when I start reload from scrollview bottom.
I tried to scroll to top but it doesn't solve it:

onContentSizeChange={(contentWidth, contentHeight) => {
   this.scrollView.scrollTo({ y: 0 });
}}

Any idea why this is happening?

<ScrollView
        ref={ref => (this.scrollView = ref)}
        refreshControl={
          <RefreshControl
            refreshing={this.props.getDataInProgress}
            onRefresh={this.reloadData.bind(this)}
          />
        }
      >
  {this.renderData()}

renderData() {
  return this.props.data.map((item, index) => {
        return ... some function that return other components 

So as I wrote if I pull down loader is visible. But if I scroll to bottom and click one some button that call same function as pull to refresh loader is not visible. EXAMPLE

1110
  • 7,829
  • 55
  • 176
  • 334
  • 1
    Please add the code for `ScrollView` component to show how it's configured. – Nishant Nair Jun 01 '19 at 05:50
  • Is your `this.props.getDataInProgress` value changing when you call your reload funtion? – Nishant Nair Jun 02 '19 at 04:43
  • Yes. It’s set to true when I clear scrollview source and false when I load them. Seems that when I set source to [] something is wrong with height and that is why loader is not visible but can’t figue how to solve it. – 1110 Jun 02 '19 at 08:30
  • Since you are emptying data, the child views inside `ScrollView` will not exist, and since the `ScrollView` doesn't have hieght, it disappears, also removing the refresh control. Try giving your `ScrollView` full size of screen or container using `flex:1` – Nishant Nair Jun 02 '19 at 09:04
  • No. I tried flex, flexGrow nothing works. I attached image with similar thing. What I notices in function that reload content before call I put `this.scrollview.scrollTo({y: 0})` but then RefreshControl is not on top. It's sometimes at the screen middle sometimes above middle depend on how much I scrolled down and call reload action. – 1110 Jun 03 '19 at 12:28

0 Answers0