import type { MouseEvent } from 'react'; import React, { forwardRef, startTransition } from 'react'; import { useNavigate } from 'dumi'; export type LinkProps = { to?: string; children?: React.ReactNode; className?: string; }; const Link = forwardRef((props, ref) => { const { to, children, ...rest } = props; const navigate = useNavigate(); const handleClick = (e: MouseEvent) => { if (!to.startsWith('http')) { // Should support open in new tab if (!e.metaKey && !e.ctrlKey && !e.shiftKey) { e.preventDefault(); startTransition(() => { navigate(to); }); } } }; return ( {children} ); }); export default Link;