vuvu vuvu - 6 days ago 6
React JSX Question

How to highlight active link-element in react js?

I have a list of link-elements, the clicked link-element shall have another background-color. What is the best way to achieve that in react.js ?

render() {
return (
<div>
<Link></Link>
<Link></Link>
....

Answer

You should simply be able to apply the acctiveClassName attribute to the Link like so

<Link to="/about" activeClassName="active">About</Link>

see this link for more info.

Comments