Created
June 3, 2022 03:07
-
-
Save ancyrweb/96544541c012fc711e77a24709c345c0 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} | |
animationIn={"slideInLeft"} | |
animationInTiming={400} | |
animationOut={"slideOutLeft"} | |
animationOutTiming={200} | |
> | |
<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