Skip to content

Commit 941a874

Browse files
committed
DND: From Serfs and Frauds 6
1 parent 13a63b8 commit 941a874

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

src/App.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@ import { HashRouter as Router } from 'react-router-dom';
33
import Layout from './components/Layout';
44
import AnimatedRoutes from './components/AnimatedRoutes';
55
import { ToastProvider } from './components/ToastProvider';
6+
import ScrollToTop from './components/ScrollToTop';
67

78
function App() {
89
return (
910
<Router>
11+
<ScrollToTop />
1012
<ToastProvider>
1113
<Layout>
1214
<AnimatedRoutes />

src/components/ScrollToTop.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
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;

0 commit comments

Comments
 (0)