Advertisement
Felanpro

React Native (Alerts)

May 14th, 2023
29
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. import { StatusBar } from 'expo-status-bar';
  2. import { StyleSheet, Text, View, TouchableWithoutFeedback, TouchableOpacity, TouchableHighlight, Alert, Image, SafeAreaView, Button } from 'react-native';
  3.  
  4. export default function App() {
  5.  
  6. return (
  7. <SafeAreaView style={styles.container}>
  8.  
  9. <Button
  10. title="Click Me"
  11.  
  12. color = "red"
  13.  
  14. onPress={() => Alert.alert("My title", "My message", [
  15. {text: "Yes", onPress: () => console.log("Yes")},
  16. {text: "No", onPress: () => console.log("No")}
  17. ])}
  18.  
  19. />
  20.  
  21. <Button
  22.  
  23. title = "Click me also"
  24.  
  25. color = "black"
  26.  
  27. onPress = {() => Alert.prompt("My title", "My message", text => console.log(text))}
  28.  
  29. />
  30.  
  31. <StatusBar style="auto" />
  32.  
  33. </SafeAreaView>
  34. );
  35. }
  36.  
  37. const styles = StyleSheet.create({
  38. container: {
  39. flex: 1,
  40. backgroundColor: 'white',
  41. justifyContent: "center",
  42. alignItems: "center"
  43. },
  44. });
  45.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement