3

I'm using the scrollview of react native v0.44.2 and I wanted to disable the pull to refresh and only generate the scroll of my views, is there another way to do it without being with scrollview?
I saw some old version, I do not know if I put this animation recently. So my code is as follows:

render() {
    return (
      <View>
        <ScrollView>
          <View style={styles.box}>

          </View>
          <View style={styles.box}>

          </View>
          <View style={styles.box}>

          </View>
          <View style={styles.box}>

          </View>
          <View style={styles.box}>

          </View>
          <View style={styles.box}>

          </View>
        </ScrollView>

      </View>
    );
  }
}

and my styles:

const styles = StyleSheet.create({

  box: {
    backgroundColor: 'blue',
    height: 300,
    width: 200,
    borderWidth: 5,
    borderColor: 'red'
  }
});
Giulio Caccin
  • 2,962
  • 6
  • 36
  • 57
Alan Russo
  • 39
  • 1
  • 1
  • 2

3 Answers3

17

I've faced the same issue and solved it by setting bounces property to false:

<ScrollView bounces={false} style={{ flex: 1 }}>
...
</ScrollView>

docs: ScrollView bounces

DᴀʀᴛʜVᴀᴅᴇʀ
  • 7,681
  • 17
  • 73
  • 127
Maybelle Pacate
  • 481
  • 7
  • 5
2

use a const refreshing = false , initially. Then on call of _onRefresh , change refreshing from false to true, and reinitialise the content of the scollview.

const refreshing = false ;
const data= [];

//your class definition
_onRefresh(){
        refreshing=true;
        this.props.clearYourData();
        data= [];
        refreshing=false;
    }

render(){
  return (
    <ScrollView refreshControl={
      <RefreshControl
        refreshing={refreshing}
        onRefresh={this._onRefresh.bind(this)}
        title="Loading..."
        />
       }
      />  >
     {data}
  </ScrollView>)
}
Subhajit
  • 876
  • 3
  • 17
  • 37
-1

Here what we can do is that we can Dissable the pull animation on Pull by using this .

<ScrollView
refreshing={false}
>
**YOUR RENDER ITEM**
</ScrollView>

I have never implemented this on scrollview but may be it can help you

HpDev
  • 2,789
  • 1
  • 15
  • 20