import { useCallback } from 'react'; import { RoutePath } from '../../shared/routes'; import { Link, LinkProps } from '../lib/components/link'; import { useHistory } from '../lib/history'; export type InternalLinkProps = Omit & { to: RoutePath; }; function InternalLink({ to, onClick, ...props }: InternalLinkProps) { const history = useHistory(); const navigate = useCallback( (e: React.MouseEvent) => { e.preventDefault(); if (onClick) { onClick(e); } return history.push(to); }, [history, to, onClick], ); return ; } const InternalLinkNamespace = Object.assign(InternalLink, { Text: Link.Text, Icon: Link.Icon, }); export { InternalLinkNamespace as InternalLink };