Created
November 11, 2022 12:58
-
-
Save hendryfoe/de1a417b0ee5cdb0c57eb19ece66689e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use client'; | |
import { type LinkProps } from 'next/link'; | |
import { useRouter } from 'next/navigation'; | |
import cn from 'classnames'; | |
type LinkPropsReal = React.PropsWithChildren< | |
Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, keyof LinkProps> & LinkProps | |
>; | |
export function PatchLink(props: LinkPropsReal) { | |
const router = useRouter(); | |
function handleOnClick() { | |
router.push(props.href as string); | |
} | |
return ( | |
<a onClick={handleOnClick} className={cn(props.className, 'hover:cursor-pointer')} title={props.title}> | |
{props.children} | |
</a> | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment