File tree Expand file tree Collapse file tree 2 files changed +16
-0
lines changed
Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -3,10 +3,12 @@ import { HashRouter as Router } from 'react-router-dom';
33import Layout from './components/Layout' ;
44import AnimatedRoutes from './components/AnimatedRoutes' ;
55import { ToastProvider } from './components/ToastProvider' ;
6+ import ScrollToTop from './components/ScrollToTop' ;
67
78function App ( ) {
89 return (
910 < Router >
11+ < ScrollToTop />
1012 < ToastProvider >
1113 < Layout >
1214 < AnimatedRoutes />
Original file line number Diff line number Diff line change 1+ import { useEffect } from 'react' ;
2+ import { useLocation } from 'react-router-dom' ;
3+
4+ function ScrollToTop ( ) {
5+ const { pathname } = useLocation ( ) ;
6+
7+ useEffect ( ( ) => {
8+ window . scrollTo ( 0 , 0 ) ;
9+ } , [ pathname ] ) ;
10+
11+ return null ;
12+ }
13+
14+ export default ScrollToTop ;
You can’t perform that action at this time.
0 commit comments