Skip to content

Instantly share code, notes, and snippets.

@ancyrweb
Created June 3, 2022 03:07
Show Gist options
  • Save ancyrweb/96544541c012fc711e77a24709c345c0 to your computer and use it in GitHub Desktop.
Save ancyrweb/96544541c012fc711e77a24709c345c0 to your computer and use it in GitHub Desktop.
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