From b3d834cb62dfbec0c20880852d029b157d46ebb7 Mon Sep 17 00:00:00 2001 From: Innei Date: Sat, 22 Jul 2023 13:04:19 +0800 Subject: [PATCH] fix: router instance --- src/components/ui/markdown/renderers/link.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/components/ui/markdown/renderers/link.tsx b/src/components/ui/markdown/renderers/link.tsx index 3212ce6c18..e5b6b070fc 100644 --- a/src/components/ui/markdown/renderers/link.tsx +++ b/src/components/ui/markdown/renderers/link.tsx @@ -1,5 +1,5 @@ import { memo, useCallback } from 'react' -import Router from 'next/router' +import { useRouter } from 'next/navigation' import type { FC, ReactNode } from 'react' import { @@ -17,6 +17,7 @@ export const MLink: FC<{ title?: string children?: ReactNode }> = memo(({ href, children, title }) => { + const router = useRouter() const handleRedirect = useCallback( (e: React.MouseEvent) => { const locateUrl = new URL(location.href) @@ -36,7 +37,7 @@ export const MLink: FC<{ case 'posts': case 'notes': case 'category': { - Router.push(toUrlParser.pathname) + router.push(toUrlParser.pathname) break } default: {