/
Muip
/
ProBody
Обзор
Документация
Войти
/
Muip
/
ProBody
Код
Запросы
0
Задачи
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
components/ExternalLink.tsx
24 строки
700 B
chmerev
Initial commit
04 июл 2024, 15:26
04 июл 2024, 15:26
fdf6383
Код
Авторство
О чём код?
import { Link } 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 function ExternalLink({ href, ...rest }: Props) { return ( <Link target="_blank" {...rest} href={href} 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); } }} /> ); }