Pretty up code. Add all my default stuff that I like
This commit is contained in:
24
components/default/ExternalLink.tsx
Normal file
24
components/default/ExternalLink.tsx
Normal file
@@ -0,0 +1,24 @@
|
||||
import { Link, RelativePathString } from 'expo-router';
|
||||
import { openBrowserAsync } from 'expo-web-browser';
|
||||
import { type ComponentProps } from 'react';
|
||||
import { Platform } from 'react-native';
|
||||
|
||||
type Props = Omit<ComponentProps<typeof Link>, 'href'> & { href: string };
|
||||
|
||||
export const ExternalLink = ({ href, ...rest }: Props) => {
|
||||
return (
|
||||
<Link
|
||||
target='_blank'
|
||||
{...rest}
|
||||
href={href as RelativePathString}
|
||||
onPress={async (event) => {
|
||||
if (Platform.OS !== 'web') {
|
||||
// Prevent the default behavior of linking to the default browser on native.
|
||||
event.preventDefault();
|
||||
// Open the link in an in-app browser.
|
||||
await openBrowserAsync(href);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
);
|
||||
};
|
||||
Reference in New Issue
Block a user