Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
NavLink
import {NavLink} from 'react-router-dom';
<li>
<NavLink to="/" activeClassName="active">
<u>Главная</u>
</NavLink>
</li>
<li>
<NavLink to="/about" activeClassName="active">
<u>О нас</u>
</NavLink>
</li>
import { Link, withRouter } from 'react-router-dom';
const Example = ({ location }) => (
<ul>
<li className={location.pathname === '/' ? 'active' : ''}>
<Link to="/">
<u>Главная</u>
</Link>
</li>
<li className={location.pathname === '/about' ? 'active' : ''}>
<Link to="/about">
<u>О нас</u>
</Link>
</li>
</ul>
);
export default withRouter(Example);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question