Feat(Frontend): Added Routing
This commit is contained in:
16
frontend/src/components/ScrollToTop.tsx
Normal file
16
frontend/src/components/ScrollToTop.tsx
Normal file
@@ -0,0 +1,16 @@
|
||||
import { useEffect } from "react";
|
||||
import { useLocation } from "react-router";
|
||||
|
||||
const ScrollToTop = () => {
|
||||
const { pathname } = useLocation();
|
||||
|
||||
// pathname changes => scroll to top
|
||||
// scrolling only on navigation
|
||||
useEffect(() => {
|
||||
window.scrollTo(0, 0);
|
||||
}, [pathname]);
|
||||
|
||||
return null;
|
||||
};
|
||||
|
||||
export default ScrollToTop;
|
Reference in New Issue
Block a user