//@flow import * as React from "react"; import {Link, Route} from "react-router-dom"; type Props = { to: string, label: string, activeOnlyWhenExact?: boolean, activeWhenMatch?: (route: any) => boolean, children?: React.Node }; class SubNavigation extends React.Component { static defaultProps = { activeOnlyWhenExact: false }; isActive(route: any) { const { activeWhenMatch } = this.props; return route.match || (activeWhenMatch && activeWhenMatch(route)); } renderLink = (route: any) => { const { to, label } = this.props; let children = null; if(this.isActive(route)) { children = ( ); } return (
  • {label} {children}
  • ); }; render() { const { to, activeOnlyWhenExact } = this.props; return ( ); } } export default SubNavigation;