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

Allow for activeClassName to be passed to Link #10107

Merged
merged 1 commit into from
Nov 28, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions docs/docs/gatsby-link.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,9 @@ following may be a good starting point:
```jsx
import { Link as GatsbyLink } from "gatsby"

const Link = ({ children, to, ...other }) => {
// Since DOM elements <a> cannot receive activeClassName,
// destructure the prop here and pass it only to GatsbyLink
const Link = ({ children, to, activeClassName, ...other }) => {
// Tailor the following test to your environment.
// This example assumes that any internal link (intended for Gatsby)
// will start with exactly one slash, and that anything else is external.
Expand All @@ -145,7 +147,7 @@ const Link = ({ children, to, ...other }) => {
// Use Gatsby Link for internal links, and <a> for others
if (internal) {
return (
<GatsbyLink to={to} {...other}>
<GatsbyLink to={to} activeClassName={activeClassName} {...other}>
{children}
</GatsbyLink>
)
Expand All @@ -164,7 +166,7 @@ export default Link

You can similarly check for file downloads:

```
```jsx
const file = /\.[0-9a-z]+$/i.test(to)

...
Expand Down