Skip to content

Instantly share code, notes, and snippets.

@ancyrweb
Last active April 2, 2020 08:09
Show Gist options
  • Save ancyrweb/d288c322a24d6142efebf1d10c9b2e8a to your computer and use it in GitHub Desktop.
Save ancyrweb/d288c322a24d6142efebf1d10c9b2e8a to your computer and use it in GitHub Desktop.
Scene.js using modals, the tutorial way
import React from 'react';
import {
StyleSheet,
TouchableOpacity,
View,
Text,
} from 'react-native';
import { useDeleteModal } from "./DeleteModal";
const styles = StyleSheet.create({
scene: {
flex: 1,
alignItems: "center",
justifyContent: "center",
},
text: {
fontSize: 20,
},
});
const Scene = () => {
const deleteModal = useDeleteModal();
async function showModal() {
const result = await deleteModal.open();
if (result) {
// We want to delete, process
} else {
// Nothing to do, the modal closes itself
}
}
return (
<View style={styles.scene}>
<TouchableOpacity onPress={showModal}>
<Text style={styles.text}>Touch to delete the item</Text>
</TouchableOpacity>
</View>
);
};
export default Scene;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment