Skip to content

Instantly share code, notes, and snippets.

@fakenickels
Created August 27, 2017 15:45
Show Gist options
  • Save fakenickels/1e636b1434152c17526ff019a64c4f38 to your computer and use it in GitHub Desktop.
Save fakenickels/1e636b1434152c17526ff019a64c4f38 to your computer and use it in GitHub Desktop.
import React from "react";
import { View, Text, Modal, TouchableOpacity } from "react-native";
export default class ViewUsingModal extends React.Component {
state = { isModalVisible: false };
toggleModal = () =>
this.setState({ isModalVisible: !this.state.isModalVisible });
render() {
return (
<View>
<TouchableOpacity onPress={this.toggleModal}>
<Text>Tap me!</Text>
</TouchableOpacity>
<Modal visible={this.state.isModalVisible}>
<View>
<Text>I am alive!</Text>
</View>
</Modal>
</View>
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment