I am trying to put a FlatList inside of a Modal but the List just spills out of the containers I have given it rather than scrolling. I have tried adding flex and such, but have had no luck getting the List to stay inside the bounds. Any suggestions?
Here is the Modal
const modalContainer = {
flexDirection: 'column',
justifyContent: 'center',
alignItems: 'center',
flex: 1,
};
const innerContainer = {
alignItems: 'center',
// flex: 1,
height: 130,
backgroundColor: colors.white.white,
borderRadius: borderRadius.sm,
width: 450,
};
render() {
const styles = styleMaker();
return (
<View>
<Modal visible = {this.props.visible}>
<View style={styles.overlay} />
<View style = {styles.modalContainer}>
<View style = {styles.innerContainer}>
{this.props.children}
</View>
</View>
</Modal>
</View>
);
}
This worked good for me:
Wrap Flatlist with a ScrollView and a View with onStartShouldSetResponder={(): boolean => true}
full example:
<Modal
....>
<View style={{ height: 300 }}>
<ScrollView>
<View onStartShouldSetResponder={(): boolean => true}>
<FlatList
....
/>
</View>
</ScrollView>
</View>
</Modal>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With