I am attempting to create a scenario where a link becomes active if the pathname matches its href value.
function Component() {
const pathname = usePathname();
return (
<div className="links">
<Link href="/">Home</Link>
<Link href="/store" className={`${pathname === this.href && "active"}`} >Store</Link>
<Link href="/actors">Actors</Link>
</div>
)}
I have attempted the above code but unfortunately, it is not yielding the desired result. Is there an alternative method I could try?