React Native Tutorial
Core Concepts
Components and APIs
React Native Useful Resources
Selected Reading
Core Concepts
- React Native - Running Android
- React Native - Running IOS
- React Native - Router
- React Native - Debugging
- React Native - Animations
- React Native - Buttons
- React Native - HTTP
- React Native - Images
- React Native - ScrollView
- React Native - Text Input
- React Native - ListView
- React Native - Flexbox
- React Native - Styling
- React Native - Props
- React Native - State
- React Native - App
- React Native - Environment Setup
- React Native - Overview
Components and APIs
- React Native - AsyncStorage
- React Native - Geolocation
- React Native - Alert
- React Native - Text
- React Native - Switch
- React Native - Status Bar
- React Native - Picker
- React Native - ActivityIndicator
- React Native - Modal
- React Native - WebView
- React Native - View
React Native Useful Resources
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
React Native - Alert
React Native - Alert
In this chapter, we will understand how to create custom Alert component.
Step 1: App.js
import React from react import AlertExample from ./alert_example.js const App = () => { return ( <AlertExample /> ) } export default App
Step 2: alert_example.js
We will create a button for triggering the showAlert function.
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, apgnItems: center , marginTop: 100 } })
Output
When you cpck the button, you will see the following −
Advertisements