From a528bd94a6e8e25010ae26a305550b211df0ddc6 Mon Sep 17 00:00:00 2001 From: polwex Date: Tue, 15 Jul 2025 17:20:58 +0700 Subject: Initial commit Generated by create-expo 3.4.3. --- components/ExternalLink.tsx | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 components/ExternalLink.tsx (limited to 'components/ExternalLink.tsx') diff --git a/components/ExternalLink.tsx b/components/ExternalLink.tsx new file mode 100644 index 0000000..dfbd23e --- /dev/null +++ b/components/ExternalLink.tsx @@ -0,0 +1,24 @@ +import { Href, Link } from 'expo-router'; +import { openBrowserAsync } from 'expo-web-browser'; +import { type ComponentProps } from 'react'; +import { Platform } from 'react-native'; + +type Props = Omit, 'href'> & { href: Href & string }; + +export function ExternalLink({ href, ...rest }: Props) { + return ( + { + 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); + } + }} + /> + ); +} -- cgit v1.2.3