Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

react native modal close when click outside

<Modal transparent={true} visible={alert} animationType='slide' onRequestClose={() => setalert(false)}>
	<TouchableOpacity activeOpacity={1} style={Styles.center} onPressOut={() => setalert(false)}>
		<TouchableWithoutFeedback>
            {/* Somethings */}
		</TouchableWithoutFeedback>
	</TouchableOpacity>
</Modal >

{/*TouchableOpacity close the modal when click and the TouchableWithoutFeedback block the touch inside the rectangle*/}
{/*Code take from: https://stackoverflow.com/questions/40483034/close-react-native-modal-by-clicking-on-overlay*/}
 
PREVIOUS NEXT
Tagged: #react #native #modal #close #click
ADD COMMENT
Topic
Name
7+4 =