Link
component does not work as expected
#32140
Unanswered
sapinder-singh
asked this question in
Help
Replies: 1 comment 8 replies
-
Hi! I think this has to do with your usage of I had to create the For your case I'd suggest to try using the |
Beta Was this translation helpful? Give feedback.
8 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Description
Since the first day I started my project in Gatsby, I haven't been able to fix this weird issue where the active link styles don't work as intended; be it using
activeClassName
,activeStyle
orgetProps
prop.I've tried all the methods. The current active link is supposed to have an
aria-current="page"
attribute andactive
class attached to it.But as I see, both of these things are not present on
Bookmarks
&About Me
links when their associated routes are visited directly by the client; as opposed to navigating internally fromHome
route.You can check it yourself by visiting e.g. /bookmarks route directly
https://blog-sapinder-dev-staging.herokuapp.com/bookmarks
Everything is fine with
Home
route whether navigating internally or externally.Steps to reproduce
Home
link is applied the necessary styles.aria-current="page"
andactive
class is shifted to the associated link element on the current route.aria-current="page"
andactive
class present on the associated link. And hence, no styles applied to it.Expected result
When landing on non-Home routes directly,
aria-current="page"
andactive
class should be attached to the associated link.Actual result
This works only when navigating internally from some other route, after the first render of the site.
Relevant Component
Browsers
Packages
Beta Was this translation helpful? Give feedback.
All reactions