Reactstrap and React-router 4.0.0-beta.6 - active <NavLink>
To use both, you'll need to rename one of those imports and use the tag prop in reactstrap NavLink. You won't be able to use the active prop on reactstrap NavLink because that logic exists in react router NavLink.
Here's what it should look like:
import { NavLink } from 'reactstrap';
import { NavLink as RRNavLink } from 'react-router-dom';
<NavLink to="/about" activeClassName="active" tag={RRNavLink}>About</NavLink>
More info here: https://github.com/reactstrap/reactstrap/issues/336
By default active
class is used. You can simply use exact
boolean property to match the exact path.
import { NavLink } from 'reactstrap';
import { NavLink as RRNavLink } from 'react-router-dom';
<NavLink exact to="/about" tag={RRNavLink}>About</NavLink>
Have a look on the source code of react-router.NavLink component: https://github.com/ReactTraining/react-router/blob/master/packages/react-router-dom/modules/NavLink.js
Since you are using reactstrap to handle styling for the navbar, you don't, and shouldn't need to rely on NavLink from react-router to do the same thing.
You can use Link from react-router instead, which deals with the routing only, and doesn't add the 'active' className when it is selected. But that's fine, because bootstrap's NavLink will do the styling for you.
import { NavLink } from 'reactstrap';
import { Link } from 'react-router-dom';
<NavLink><Link to="/about">About</Link></NavLink>