Files
Assemblr/src/components/Hyperlink/Hyperlink.tsx

27 lines
590 B
TypeScript

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 {
}
});
};
return (
<TouchableOpacity onPress={handlePress}>
{children}
</TouchableOpacity>
);
};
export default Hyperlink;