diff options
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 || ''}`} > |
