Listing 12-3: Using the exact attribute on NavLink components
<ul>
<li><NavLink exact to="/" activeClassName="active">Home</NavLink></li>
<li><NavLink exact to="/aboutUs" activeStyle={{color:'green'}}>About Us</NavLink>
<ul>
<li><NavLink exact to="/aboutUs/team" activeClassName="active">Meet the Team</NavLink></li>
<li><NavLink exact to="/aboutUs/history" activeClassName="active">Company History</NavLink></li>
</ul>
</li>
<li><NavLink exact to="/contactUs" activeClassName="active">Contact Us</NavLink></li>
</ul>
Download the examples, report issues, and ask/answer questions in the discussion area by visiting the book's github page. All of the code for the book is also available on codesandbox.io for you to play around with.
ReactJS Foundations is published by John Wiley and Sons, Inc and is available in paperback and eBook.