2018-07-11 14:59:01 +02:00
|
|
|
//@flow
|
2018-07-11 21:01:29 +02:00
|
|
|
import * as React from "react";
|
2018-07-11 14:59:01 +02:00
|
|
|
import { Route, Link } from "react-router-dom";
|
|
|
|
|
|
|
|
|
|
type Props = {
|
|
|
|
|
to: string,
|
2018-07-12 11:33:41 +02:00
|
|
|
label: string,
|
|
|
|
|
activeOnlyWhenExact?: boolean
|
2018-07-11 14:59:01 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class PrimaryNavigationLink extends React.Component<Props> {
|
|
|
|
|
renderLink = (route: any) => {
|
2018-07-12 11:33:41 +02:00
|
|
|
const { to, label } = this.props;
|
2018-07-11 14:59:01 +02:00
|
|
|
return (
|
|
|
|
|
<li className={route.match ? "is-active" : ""}>
|
2018-07-12 11:33:41 +02:00
|
|
|
<Link to={to}>{label}</Link>
|
2018-07-11 14:59:01 +02:00
|
|
|
</li>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
render() {
|
|
|
|
|
const { to, activeOnlyWhenExact } = this.props;
|
|
|
|
|
return (
|
|
|
|
|
<Route path={to} exact={activeOnlyWhenExact} children={this.renderLink} />
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default PrimaryNavigationLink;
|