Files
SCM-Manager/scm-ui/src/components/navigation/PrimaryNavigationLink.js

30 lines
643 B
JavaScript
Raw Normal View History

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,
label: string,
activeOnlyWhenExact?: boolean
2018-07-11 14:59:01 +02:00
};
class PrimaryNavigationLink extends React.Component<Props> {
renderLink = (route: any) => {
const { to, label } = this.props;
2018-07-11 14:59:01 +02:00
return (
<li className={route.match ? "is-active" : ""}>
<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;