I have a FlatList
which is wrapped in a View.
<View {...this._panResponder.panHandlers}>
<FlatList .../>
</View>
the View is a panResponder
, so how to disable FlatList's scrolling when onPanResponderGrant
triggers.
The documentation states that a FlatList
has the props of a ScrollView
:
and thus inherits it's props (as well as those of ScrollView)
If you check the documentation for ScrollView
, you'll see that all you need to do is set the scrollEnabled
prop to false to disable scrolling. How and where you choose to do this will be up to you since you didn't really post any code. A simple way to handle this would be to use state:
<FlatList
...
scrollEnabled={this.state.scrollEnabled}
/>
// Change the state to the appropriate value in onPanResponderGrant:
// To enable:
this.setState({ scrollEnabled: true })
// To disable:
this.setState({ scrollEnabled: false })
You can save ref to FlatList and call setNativeProps on this ref:
this.flatList.setNativeProps({ scrollEnabled: false })
Use ScrollView instead of View.