I am using semantic ui react and I am using NavLink with Menu.Item for routing.
Below is my navbar component:
const Navbar = () => (
<div>
<Container>
<Menu secondary stackable widths={4}>
<Menu.Item>
<img src={Logo} alt="header" />
</Menu.Item>
<Menu.Item as={NavLink} to="/" name="home">
<Icon name="home" size="large" />
<p>Home</p>
</Menu.Item>
<Menu.Item as={NavLink} to="/data" name="data">
<Icon name="dashboard" size="large" />
<p>Dashboard</p>
</Menu.Item>
<Menu.Item as={NavLink} to="/user" name="user">
<Icon name="user" size="large" />
<p>User</p>
</Menu.Item>
</Menu>
</Container>
</div>
);
Now here is where the issue resides. The routing works fine but for some reason the 'Home' Menu Item is always active.
However the other two routes work fine (i.e. are only set 'active' when route is correct)
Here is what it looks like with /dashboard route active
The code for the routes in my App.jsx:
<Switch>
<Route exact path="/" component={Home} />
<Route path="/data" component={Dashboard} />
<Route path="/user" component={User} />
</Switch>
The photo above should give you a clear indication of the issue!
Any input would be appreciated!!
exactprop to your Menu Item