[React] React Router: activeStyle & activeClassName

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.

 

const Links = () =>
    <nav >
        <Link activeStyle={{color: 'green'}} to="/">HomeLink>
        <Link activeStyle={{color: 'green'}} to="/about">AboutLink>
        <Link activeClassName="active" to="/contact">ContactLink>
    nav>;

 

.active{
    color: green;
}

 

[React] React Router: activeStyle & activeClassName_第1张图片

你可能感兴趣的:([React] React Router: activeStyle & activeClassName)