indexLink in React Router v4
<Indexlink>
doesn't exist in RRv4 because <IndexRoute>
and the whole concept of indexes doesn't really exist in RRv4. Remember that Links and Routes are directly related.
So instead, just use <NavLink>
.
Have a read about NavLink on the official docs:
NavLink
- A special version of the that will add styling attributes to the rendered element when it matches the current URL.
If you need more control over the URL matching, you can use the strict
or exact
props.
Per Chris, the correct answer was to continue to use NavLink and use exact. Strict did not work in this case.
<NavLink exact to="/" activeClassName="active" activeStyle={{fontWeight: 'bold'}}>chris is awesome</NavLink>
Just in case another comes across this!