Skip to content

Commit

Permalink
<Link>: allow className and activeClass props (#386)
Browse files Browse the repository at this point in the history
* <Link>: allow `className` and `activeClass` props

Fixes #365

* Update index.js
  • Loading branch information
developit authored Oct 9, 2020
1 parent 662e83a commit f9297f1
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions match/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,16 @@ export class Match extends Component {
}
}

export const Link = ({ activeClassName, path, ...props }) => (
<Match path={path || props.href}>
{ ({ matches }) => (
<StaticLink {...props} class={[props.class || props.className, matches && activeClassName].filter(Boolean).join(' ')} />
) }
</Match>
);
export function Link({ class: c, className, activeClass, activeClassName, path, ...props }) {
const inactive = [c, className].filter(Boolean).join(' ');
const active = [c, className, activeClass, activeClassName].filter(Boolean).join(' ');
return (
<Match path={path || props.href}>
{ ({ matches }) => (
<StaticLink {...props} class={matches ? active : inactive} />
) }
</Match>
);
}

export default Match;

0 comments on commit f9297f1

Please sign in to comment.