The ability to reply to discussions is limited to PRO members. Want to join in the discussion? Click here to subscribe now.

React Router: activeStyle & activeClassName

React Router: activeStyle & activeClassName

1:03
react-router provides two props for setting a specific style on a Link component whose path matches our current route. activeStyle allows for an inline style while activeClassName allows for an class defined in an external stylesheet.
Watch this lesson now
Avatar
egghead.io

react-router provides two props for setting a specific style on a Link component whose path matches our current route. activeStyle allows for an inline style while activeClassName allows for an class defined in an external stylesheet.

Avatar
Hozefa

Is it possible to use className & activeClassName on the same element? I ask this because I have a default class that I need to be applied to all my links and an active class when link is active. Currently I have something like

const classes = classNames({
            'vx_globalNav-links': true,
            'vx_isActive': (route === this.props.location),
        });
        return classes;
In reply to egghead.io
HEY, QUICK QUESTION!
Joel's Head
Why are we asking?