File tree 2 files changed +15
-0
lines changed
2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -7,11 +7,13 @@ import About from './pages/AboutMe';
7
7
import Projects from './pages/Projects' ;
8
8
import Contact from './pages/Contact' ;
9
9
import ProjectSingle from './pages/ProjectSingle' ;
10
+ import ScrollToTop from './components/ScrollToTop' ;
10
11
11
12
function App ( ) {
12
13
return (
13
14
< div className = " bg-secondary-light dark:bg-primary-dark transition duration-300" >
14
15
< Router >
16
+ < ScrollToTop />
15
17
< AppHeader > </ AppHeader >
16
18
< Routes >
17
19
< Route path = "/" element = { < Home /> } />
Original file line number Diff line number Diff line change
1
+ import { useEffect } from 'react' ;
2
+ import { useLocation } from 'react-router-dom' ;
3
+
4
+ const ScrollToTop = ( ) => {
5
+ const { pathname } = useLocation ( ) ;
6
+
7
+ useEffect ( ( ) => {
8
+ window . scrollTo ( 0 , 0 ) ;
9
+ } , [ pathname ] ) ;
10
+ return null ;
11
+ } ;
12
+
13
+ export default ScrollToTop ;
You can’t perform that action at this time.
0 commit comments