Sometimes, we want to display a hyperlink in a React Native app.
In this article, we’ll look at how to display a hyperlink in a React Native app.
How to display a hyperlink in a React Native app?
To display a hyperlink in a React Native app, we can use the Text
component.
For instance, we write
import { Linking } from "react-native";
//...
export default () => {
//...
return (
<Text
style={{ color: "blue" }}
onPress={() => Linking.openURL("http://example.com")}
>
Example
</Text>
);
};
to add a Text
component.
We set its onPress
prop to a function that calls Linking.openURL
to open the URL we want to go to in a web view.
And we set the color
to 'blue'
to make it look like a link.
Conclusion
To display a hyperlink in a React Native app, we can use the Text
component.