问题
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'
}
});
回答1:
I've faced the same issue, and solved it by setting bounces property to false:
<ScrollView bounces={false} style={{ flex: 1 }}>
...
</ScrollView>
docs: https://facebook.github.io/react-native/docs/scrollview.html#bounces
回答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>)
}
回答3:
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
来源:https://stackoverflow.com/questions/45411403/react-native-scrollview-disable-pull-to-refresh