Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/components/ScrollToTop/ScrollToTop.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { useEffect } from "react";
import { useLocation } from "react-router-dom";

export default function ScrollToTop() {
const { pathname } = useLocation();

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

return null;
}
2 changes: 2 additions & 0 deletions src/router/RouterPages.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ import MissingPeople from '../pages/MissingPeople';
import ContactUs from '../pages/Contactus';
import PostMissingPerson from '../pages/PostMissingPerson';
import MissingPerson from '../pages/MissedPerson';
import ScrollToTop from '../components/ScrollToTop/ScrollToTop'

const RouterPages = () => {
return (
<Router>
<ScrollToTop/>
<Navbar />
<Switch>
<Route path="/" exact component={Home} />
Expand Down