React Native – Button

In this example will see how to use button component. Here we will use onPress props to display Alert with message “You clicked the button!

import React, { Component } from 'react';
import { Alert, AppRegistry, Button, StyleSheet, View } from 'react-native'; 

export default class App extends Component {  

  onPressButton() {  
    Alert.alert('You clicked the button!')  
}  

  render() {  
      return (  
          <View style={styles.container}>  
         <Button  
                        onPress={this.onPressButton}  
                        title="PRESS ME"
                    />   
          </View>  
      );  
  }  
}  

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center'
  },
  setFontSize: {
    fontSize: 25 // Define font size here in Pixels
  }});