-
Hey everyone, I currently do some styling in my project and struggle with adding a feature to the navbar. When a navbar icon is clicked there should be another icon, as long as the user is on the according page. The present code doesn't work (at first, I tried it only with the favorite page), but I don't know why. I searched in the discussion board and the internet for similar problems, but couldn't find something. Can anyone please help? Here is the PR: DorisW3/capstone-project#18 Thank you :-) |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
In <StyledLink href={"/favorites"}>
{router.pathname === "/favorites" ? <FilledStar /> : <Star />}
</StyledLink> |
Beta Was this translation helpful? Give feedback.
In
Navbar.js
you drop theisActive
prop since you're not using it. Instead you define what the children of theStyledLink
should be by checking for the current pathname. If it matches the "/favorites" string you show the filled star and the unfilled otherwise. You had a typo here as well; it's "favorites" with the "s" in the end.