import type { NavigationAction } from '@react-navigation/core' ; import * as React from 'react' ; import { GestureResponderEvent , Platform , Text , TextProps } from 'react-native' ; import useLinkProps from './useLinkProps' ; import type { To } from './useLinkTo' ; type Props < ParamList extends ReactNavigation . RootParamList > = { to : To < ParamList > ; action ? : NavigationAction ; target ? : string ; onPress ? : ( e : React . MouseEvent < HTMLAnchorElement , MouseEvent > | GestureResponderEvent ) => void ; } & ( TextProps & { children : React . ReactNode ; } ) ; param props . to param props . action param props . children export default function Link < ParamList extends ReactNavigation . RootParamList > ( { to , action , ... rest } ) { const props = useLinkProps < ParamList > ( { to , action } ) ; const onPress = ( e ) => { if ( 'onPress' in rest ) { rest . onPress ?. ( e ) ; } props . onPress ( e ) ; } ; return React . createElement ( Text , { ... props , ... rest , ... Platform . select ( { web : { onClick : onPress } as any , default : { onPress } , } ) , } ) ; }