Skip to content

navbar - toggle icons, when the according page is chosen #722

Answered by Kheirah
DorisW3 asked this question in Web
Discussion options

You must be logged in to vote

In Navbar.js you drop the isActive prop since you're not using it. Instead you define what the children of the StyledLink 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.

<StyledLink href={"/favorites"}>
  {router.pathname === "/favorites" ? <FilledStar /> : <Star />}
</StyledLink>

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@DorisW3
Comment options

Answer selected by MerleMak
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Web
Labels
None yet
2 participants