const MenuLink = ({ label, to , activeOnlyWhenExact }) => { return ( <Route path={ to } exact={ activeOnlyWhenExact } children={({ match })=>{ var active = match ? 'active' : ''; return ( <li className={`default-class ${active} `}> <Link to={ to }> { label } </Link> </li> ) }} /> ) }
using:
<MenuLink label="Home" to="/" activeOnlyWhenExact={ true }/>