import React from 'react'; import {isURL} from '@ywfe/utils'; import {YLinkProps} from './router.interface'; import {useHistory} from './useHistory'; export const YLink: React.FC = ({ goto = '', to = '', target = '_self', children }) => { const history = useHistory(); const linkTo = (event: React.MouseEvent) => { event.preventDefault(); if(to) { history.push(to); } else { history.goto(goto); } } return ( <> { isURL(to) ? ( {children} ) : ( {children} ) } ); };