diff options
| author | Rafi Zadanly <zadanlyr@gmail.com> | 2023-03-31 11:17:55 +0700 |
|---|---|---|
| committer | Rafi Zadanly <zadanlyr@gmail.com> | 2023-03-31 11:17:55 +0700 |
| commit | 092dc7fc49246580023a8b97101d51845c81bf04 (patch) | |
| tree | 089121b3c6cf46429411ae6edc6c4babfebe0e0d /src/core/components/elements/Link/Link.jsx | |
| parent | f23d32a4b8402904e8daa7b906c03a64104ed253 (diff) | |
iframe content
Diffstat (limited to 'src/core/components/elements/Link/Link.jsx')
| -rw-r--r-- | src/core/components/elements/Link/Link.jsx | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/core/components/elements/Link/Link.jsx b/src/core/components/elements/Link/Link.jsx index 75fc6ca8..557abbc4 100644 --- a/src/core/components/elements/Link/Link.jsx +++ b/src/core/components/elements/Link/Link.jsx @@ -1,10 +1,18 @@ import NextLink from 'next/link' +import { useRouter } from 'next/router' +import { useEffect } from 'react' const Link = ({ children, ...props }) => { + const router = useRouter() + + useEffect(() => { + router.events.on('routeChangeStart', () => window.scrollTo({ top: 0, behavior: 'smooth' })) + }, [router]) + return ( <NextLink {...props} - onClick={() => window.scrollTo({ top: 0, behavior: 'smooth' })} + // onClick={() => window.scrollTo({ top: 0, behavior: 'smooth' })} scroll={false} className={`block font-medium text-red_r-11 ${props?.className || ''}`} > |
