diff --git a/src/hooks/useScrollToTop.tsx b/src/hooks/ScrollToTop.tsx similarity index 83% rename from src/hooks/useScrollToTop.tsx rename to src/hooks/ScrollToTop.tsx index 6fc03c0..bdcabf1 100644 --- a/src/hooks/useScrollToTop.tsx +++ b/src/hooks/ScrollToTop.tsx @@ -1,10 +1,10 @@ -import { useLayoutEffect } from 'react'; +import { useEffect } from 'react'; import { useRouter } from 'next/router'; export function useScrollToTop() { const router = useRouter(); - useLayoutEffect(() => { + useEffect(() => { const handleRouteChange = () => { window.scrollTo(0, 0); }; @@ -14,4 +14,6 @@ export function useScrollToTop() { router.events.off('routeChangeComplete', handleRouteChange); }; }, [router.events]); + + return null; } diff --git a/src/hooks/index.ts b/src/hooks/index.ts index 4ef28a2..3ffc027 100644 --- a/src/hooks/index.ts +++ b/src/hooks/index.ts @@ -1,2 +1,2 @@ -export * from './useScrollToTop'; +export * from './ScrollToTop'; export * from './useStateContext'; diff --git a/src/pages/layout.tsx b/src/pages/layout.tsx index 9911375..e2e2ace 100644 --- a/src/pages/layout.tsx +++ b/src/pages/layout.tsx @@ -1,11 +1,8 @@ import { CssBaseline, styled } from '@mui/material'; import { Disclaimer } from '~/components'; import { Footer, Header } from '~/containers'; -import { useScrollToTop } from '~/hooks'; export default function Layout({ children }: { children: React.ReactNode }) { - useScrollToTop(); - return ( <>