Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

activeClassName with class and className for Link #365

Closed
rwhendry opened this issue Apr 6, 2020 · 3 comments · Fixed by #386
Closed

activeClassName with class and className for Link #365

rwhendry opened this issue Apr 6, 2020 · 3 comments · Fixed by #386
Labels

Comments

@rwhendry
Copy link

rwhendry commented Apr 6, 2020

I find something interseting in the Link Component with the activeClassName

  <Link href="/" activeClassName="active" className="className"/>

if the match route it will give the only the "className" class but if i change it to this

  <Link href="/" activeClassName="active" class="className"/>

then it will give the "className" and "active" as its class.

Is this intended?

@developit
Copy link
Member

This is intended. preact-router is designed for use with Preact, which means it expects a class prop, not className.

@evenfrost
Copy link

@developit according to your comment, it is possible and allowed to use both class and className in Preact. In my own case, I'm using className everywhere just because I have separate projects on React and don't want to have issues memorizing the proper syntax when switching between them.

Why just don't support both? And following this logic, the active class should be named activeClass, not activeClassName then.

@developit
Copy link
Member

@evenfrost TBH you're right, there's not really a good reason for preact-router should take a stance on this. I've opened #386 that implements both your suggestions (className support as well as activeClass). Thanks for the nudge!

developit added a commit that referenced this issue Oct 9, 2020
* <Link>: allow `className` and `activeClass` props

Fixes #365

* Update index.js
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants