Skip to content

Commit

Permalink
Fixed issues when the page is already in the homepage.
Browse files Browse the repository at this point in the history
  • Loading branch information
PranavKeshav24 committed May 19, 2024
1 parent 6d273ff commit 5df9446
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/Components/Footer/Footer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,23 @@ import footer_logo from "../Assets/logo_big.png";
import instagram_icon from "../Assets/instagram_icon.png";
import pintester_icon from "../Assets/pintester_icon.png";
import whatsapp_icon from "../Assets/whatsapp_icon.png";
import { Link } from "react-router-dom";
import { Link, useLocation } from "react-router-dom";
import { ShopContext } from "../../Context/ShopContext";

const Footer = () => {
const { theme } = useContext(ShopContext);
const location = useLocation();

const handleLogoClick = () => {
if (location.pathname === "/") {
window.scrollTo({ top: 0, behavior: "smooth" });
}
};

return (
<div className="footer">
<div className="footer-logo">
<Link className="nav-logo-link" to="/">
<Link className="nav-logo-link" to="/" onClick={handleLogoClick}>
<img src={footer_logo} alt="ShopNex Logo" />
<p className={`footer_${theme}`}>ShopNex</p>
</Link>
Expand Down

0 comments on commit 5df9446

Please sign in to comment.