add the ScrollToTop Component

Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
aryabenade
2026-04-26 23:43:33 +05:30
parent 0dbba7f80e
commit 13780803ba
2 changed files with 14 additions and 0 deletions

View File

@@ -0,0 +1,12 @@
import { useEffect } from "react";
import { useLocation } from "react-router-dom";
export function ScrollToTop() {
const { pathname } = useLocation();
useEffect(() => {
window.scrollTo(0, 0);
}, [pathname]);
return null;
}

View File

@@ -5,11 +5,13 @@ import "./index.css";
import { Provider } from "react-redux";
import { store } from "./Redux/Store";
import { Toaster } from "sonner";
import { ScrollToTop } from "./components/ScrollToTop";
createRoot(document.getElementById("root")!).render(
<Provider store={store}>
<BrowserRouter>
<Toaster position="top-right" richColors duration={2000} closeButton />
<ScrollToTop />
<App />
</BrowserRouter>
</Provider>