Last active
April 2, 2020 08:09
-
-
Save ancyrweb/d288c322a24d6142efebf1d10c9b2e8a to your computer and use it in GitHub Desktop.
Scene.js using modals, the tutorial way
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 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