Skip to content

Commit

Permalink
페이지 이동시 최상단으로 오게 설정
Browse files Browse the repository at this point in the history
  • Loading branch information
mnmn092631 committed Sep 20, 2023
1 parent f70c407 commit 8fa6bc2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions front/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import Login from "pages/Login";
import WriteNotice from "pages/notice/WriteNotice";
import ATCWorkList from "pages/ATCWorkList";
import YardWorkList from "pages/YardWorkList";
import ScrollToTop from "components/ScrollToTop";

function App() {
const store = useStore();
Expand All @@ -21,6 +22,7 @@ function App() {
<ReduxProvider store={store}>
<ThemeProvider theme={theme}>
<GlobalStyle />
<ScrollToTop />
<Modal />
<Routes>
<Route element={<Layout />}>
Expand Down
14 changes: 14 additions & 0 deletions front/src/components/ScrollToTop.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { useEffect } from "react";
import { useLocation } from "react-router-dom";

const ScrollToTop = () => {
const { pathname } = useLocation();

useEffect(() => {
window.scrollTo(0, 0);
}, [pathname]);

return null;
};

export default ScrollToTop;

0 comments on commit 8fa6bc2

Please sign in to comment.