Skip to content

Commit

Permalink
refactor: rollback hook changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Onizuka-wl committed Oct 1, 2024
1 parent 354fe08 commit d5865d5
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
6 changes: 4 additions & 2 deletions src/hooks/useScrollToTop.tsx → src/hooks/ScrollToTop.tsx
Original file line number Diff line number Diff line change
@@ -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);
};
Expand All @@ -14,4 +14,6 @@ export function useScrollToTop() {
router.events.off('routeChangeComplete', handleRouteChange);
};
}, [router.events]);

return null;
}
2 changes: 1 addition & 1 deletion src/hooks/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export * from './useScrollToTop';
export * from './ScrollToTop';
export * from './useStateContext';
3 changes: 0 additions & 3 deletions src/pages/layout.tsx
Original file line number Diff line number Diff line change
@@ -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 (
<>
<CssBaseline />
Expand Down

0 comments on commit d5865d5

Please sign in to comment.