minor govno
This commit is contained in:
27
src/components/Hyperlink/Hyperlink.tsx
Normal file
27
src/components/Hyperlink/Hyperlink.tsx
Normal file
@@ -0,0 +1,27 @@
|
||||
import React, {ReactNode} from 'react';
|
||||
import {TouchableOpacity, Linking} from 'react-native';
|
||||
|
||||
type HyperlinkProps = {
|
||||
url: string;
|
||||
children: ReactNode;
|
||||
};
|
||||
|
||||
const Hyperlink: React.FC<HyperlinkProps> = ({url, children}) => {
|
||||
const handlePress = () => {
|
||||
Linking.canOpenURL(url).then(supported => {
|
||||
if (supported) {
|
||||
Linking.openURL(url);
|
||||
} else {
|
||||
console.log("Don't know how to open URI: " + url);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<TouchableOpacity onPress={handlePress}>
|
||||
{children}
|
||||
</TouchableOpacity>
|
||||
);
|
||||
};
|
||||
|
||||
export default Hyperlink;
|
||||
Reference in New Issue
Block a user