- Create Components folder under src folder
- Add HyperLinkEXP.js file and add below Code
import React, { Component } from "react";
import { StyleSheet, Text, View, Linking } from "react-native";
export default class HyperLinkEXP extends Component {
render() {
return (
<View style={styles.MainContainer}>
<Text>HyperLink Example</Text>
<Text
style={styles.TextStyle}
onPress={() => Linking.openURL("https://google.com")}
>
Click Here To Open Google.
</Text>
</View>
);
}
}
const styles = StyleSheet.create({
MainContainer: {
flex: 1,
justifyContent: "center",
alignItems: "center"
},
TextStyle: {
color: "#E91E63",
textDecorationLine: "underline"
}
});
- Open App.js file and update code as below
import React from 'react';
import { View,StyleSheet } from 'react-native';
import HyperLinkEXP from './src/Component/HyperLinkEXP'
const App=()=> {
return (
<View style={styles.container}>
<HyperLinkEXP/>
</View>
);
}
export default App;
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
paddingTop:80
},
});
No comments:
Post a Comment