[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="/">Home</Link>
        <Link activeStyle={{color: 'green'}} to="/about">About</Link>
        <Link activeClassName="active" to="/contact">Contact</Link>
    </nav>;

 

.active{
    color: green;
}

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM