Last active
June 3, 2022 02:57
-
-
Save ancyrweb/8aeae5f6039bf32beda36487d48230b0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useCallback, useState } from "react"; | |
import { StyleSheet, Text, View } from "react-native"; | |
import Modal from "react-native-modal"; | |
export default function App() { | |
const [visible, setVisible] = useState(false); | |
const showModal = useCallback(() => setVisible(true), []); | |
const hideModal = useCallback(() => setVisible(false), []); | |
return ( | |
<View style={styles.container}> | |
<Text onPress={showModal}>Open the modal</Text> | |
<Modal | |
isVisible={visible} | |
onBackdropPress={hideModal} | |
onBackButtonPress={hideModal} | |
> | |
<View style={styles.content}> | |
<Text>This is a modal !</Text> | |
</View> | |
</Modal> | |
</View> | |
); | |
} | |
const styles = StyleSheet.create({ | |
container: { | |
flex: 1, | |
backgroundColor: "#fff", | |
alignItems: "center", | |
justifyContent: "center", | |
}, | |
content: { | |
backgroundColor: "white", | |
padding: 20, | |
}, | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment