Skip to content

Commit

Permalink
Fixed scroll on routing
Browse files Browse the repository at this point in the history
  • Loading branch information
mansisindhu committed Feb 13, 2022
1 parent 190cc5f commit 7acf87b
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/App.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Switch, Route } from "react-router-dom";
import { Switch, Route, useLocation } from "react-router-dom";
import { useDispatch } from "react-redux";
import { useEffect } from "react";

Expand All @@ -13,6 +13,12 @@ import WishlistPage from "./pages/WishlistPage";

const App = () => {
const dispatch = useDispatch();
const {pathname} = useLocation();

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

useEffect(() => {
dispatch(fetchUser());
Expand Down

0 comments on commit 7acf87b

Please sign in to comment.