vuvu
vuvu

Reputation: 5328

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>
  ....

Upvotes: 1

Views: 6685

Answers (1)

Chaim Friedman
Chaim Friedman

Reputation: 6253

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.

Upvotes: 2

Related Questions