Is it possible to close react native modal by clicking on overlay when transparent
option is true
? Documentation doesn\'t provide anything about it
Here is my perfectly working solution
MODAL CODE:
const ListInModal = ({ showListModal, onClose, data, onSelectItem }) => {
return (
onClose(false)}>
onClose(false)} style={styles.centeredView}>
{data.map((item, index) => (
<>
{
onSelectItem(item);
onClose(false);
}}
style={{ height: 43, justifyContent: 'center' }}
>
{item.label}
{index <= data.length - 2 && (
)}
>
))}
);
};
STYLING:
const styles = StyleSheet.create({
centeredView: {
flex: 1,
justifyContent: 'center',
backgroundColor: '#00000099',
},
modalView: {
marginHorizontal: wp('5%'),
marginVertical: hp('10%'),
backgroundColor: colors.popupBlack,
borderRadius: 20,
shadowColor: '#000',
shadowOffset: {
width: 0,
height: 2,
},
shadowOpacity: 0.25,
shadowRadius: 3.84,
elevation: 5,
},
itemLabel: {
fontSize: wp('5%'),
color: colors.white,
paddingHorizontal: (24 / 375) * screenWidth,
},
});
USAGE:
setshowListModal(bool)}
onSelectItem={(item) => onPressApplicationType(item.label)}
/>