1import * as React from 'react'; 2import { Alert, Platform } from 'react-native'; 3 4import Button from '../components/Button'; 5import { Page, Section } from '../components/Page'; 6 7export default function AlertExample() { 8 const showPrompt = () => { 9 Alert.prompt('Enter a value', undefined, (text) => console.log(`You entered ${text}`)); 10 }; 11 12 const showAlert = () => { 13 Alert.alert('Alert Title', 'My Alert Msg', [ 14 { 15 text: 'Ask me later', 16 onPress: () => console.log('Ask me later pressed'), 17 }, 18 { 19 text: 'Cancel', 20 onPress: () => console.log('Cancel Pressed'), 21 style: 'cancel', 22 }, 23 { text: 'OK', onPress: () => console.log('OK Pressed') }, 24 ]); 25 }; 26 27 return ( 28 <Page> 29 <Section title="Default" row> 30 <Button disabled={Platform.OS !== 'ios'} onPress={showPrompt} title="Prompt for a value" /> 31 <Button onPress={showAlert} title="Give me some options" /> 32 </Section> 33 </Page> 34 ); 35} 36 37AlertExample.navigationOptions = { 38 title: 'Alert', 39}; 40