Skip to content

Instantly share code, notes, and snippets.

@abranhe
Created December 28, 2018 20:41
Show Gist options
  • Save abranhe/28252e60728a56feca8717bd9427c91d to your computer and use it in GitHub Desktop.
Save abranhe/28252e60728a56feca8717bd9427c91d to your computer and use it in GitHub Desktop.
React Native Alert

Output

R

After the user click it!

import React from 'react'
import { Alert, Text, TouchableOpacity, StyleSheet } from 'react-native'
const AlertExample = () => {
const showAlert = () =>{
Alert.alert(
'You need to...'
)
}
return (
<TouchableOpacity onPress = {showAlert} style = {styles.button}>
<Text>Alert</Text>
</TouchableOpacity>
)
}
export default AlertExample
const styles = StyleSheet.create ({
button: {
backgroundColor: '#4ba37b',
width: 100,
borderRadius: 50,
alignItems: 'center',
marginTop: 100
}
})
import React from 'react'
import AlertExample from './AlertExample.js'
const App = () => {
return (
<AlertExample />
)
}
export default App
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment