Answer the question
In order to leave comments, you need to log in
How to make ReactJs Menu Active Link?
Good evening, there was such a situation, there is a router
<Router history={browserHistory}>
<Route path="/" component={Root}>
<IndexRoute component={Home}/>
<Route path="projects" component={Projects} />
<Route path="projects/one" component={ProjectsLevel} />
<Route path="projects/two" component={ProjectIngrad} />
</Route>
</Router>
<ul>
<li>
<Link to="/" className="menu__link" activeClassName="menu__link_active" onlyActiveOnIndex={true}>Главная</Link>
</li>
<li>
<Link to="projects" className="menu__link" activeClassName="menu__link_active">Проекты</Link>
</li>
</ul>
Answer the question
In order to leave comments, you need to log in
As far as I know, the router takes the route from historyApi/hashHistory.
Those. this should be enough.
Second. Why can't you invest? Separate page? AND???
<Route path="projects" component={Projects} >
<Route path="one" component={ProjectsLevel} />
<Route path="two" component={ProjectIngrad} />
</Route>
const Projects = ({ children }) => children || <div>Projects</div>
use NavLink instead of Link.
They have a default activeStyle property.
<NavLink activeStyle={{backgroundColor:"#353d46"}} className={style.link} to="/main/settings">
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question