79088594

Date: 2024-10-15 06:05:45
Score: 0.5
Natty:
Report link

I guess i worked my way through the issue, i removed the <Link> component which was covering my cart div in my navigation bar and instead i am now using the useRouter() hook for navigating to my Cart. I firstly defined a function like this.

function handleClick(e, path) {
  e.preventDefault();
  router.push(path);
  router.refresh();   
}

Then pass it to the onClick of my cart div

<div onClick={(e) => handleClick(e, "/Cart")}>
   <PiShoppingCartDuotone className="nav_link_icon" />
   <h1 className={pathname === '/Cart' ? "highlight" : ""}>Cart</h1>
</div>

Now it refreshes the data everytime i navigate to my Cart also it will not take a full page reload while doing that.

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: Daksh