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
2 changes: 2 additions & 0 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import Footer from "./components/Footer";
import ScrollProgressBar from "./components/ScrollProgressBar";
import { Toaster } from "react-hot-toast";
import Router from "./Routes/Router";
import ScrollToTop from "./components/ScrollToTop";

const FULLSCREEN_ROUTES = ["/signup", "/login"];

Expand All @@ -13,6 +14,7 @@ function App() {

return (
<div className="relative flex flex-col min-h-screen">
<ScrollToTop/>
{!isFullscreen && <ScrollProgressBar />}

{!isFullscreen && <Navbar />}
Expand Down
15 changes: 15 additions & 0 deletions src/components/ScrollToTop.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import {useEffect} from 'react';
import {useLocation} from 'react-router-dom';
/**
* Resets the window scroll position to the top
* whenever the route pathname changes.
*/
function ScrollToTop() {
const location = useLocation();
useEffect(() => {
window.scrollTo(0, 0);
},[location.pathname]);

return null;
}
export default ScrollToTop;