import React from 'react' ; import { Browser } from '../../libs/browser' ; import { Linking } from '../../libs/linking' ; import { Platform } from '../../libs/platform' ; import { Button , ButtonProps } from './Button' ; import { Link , LinkProps } from './Link' ; export type ButtonLinkProps = ButtonProps & { href ? : LinkProps [ 'href' ] ; onPress ? : never ; openOnNewTab ? : LinkProps [ 'openOnNewTab' ] ; } ; export const ButtonLink = React . memo ( ( props ) => { const { href , openOnNewTab , ... otherProps } = props ; if ( Platform . OS === 'web' && href ) { return ( < Link analyticsLabel = { otherProps . analyticsLabel } href = { href } openOnNewTab = { openOnNewTab } > < Button { ... otherProps } onPress = { undefined } / > < /Link>); } return ( < Button { ... otherProps } onPress = { href ? href . startsWith ( 'http' ) ? ( ) => Browser . openURL ( href ) : ( ) => Linking . openURL ( href ) : undefined } />); } ) ; ButtonLink . displayName = 'ButtonLink' ;