React activeClassName is not working on server

Viewed 160

React activeClassName="active" is not working on server. It is working properly on my local.

Navbar.js

<ul className="sidebar-elements">
    <li><NavLink to="/" exact activeClassName="active">Dashboard</NavLink></li>
    <li><NavLink exact to="/about" activeClassName="active">About Us</NavLink></li>
    <li><NavLink exact to="/contact" activeClassName="active">Contact Us</NavLink></li>
</ul>

Routes.js

<Switch>
        <Route exact path="/" component={Dashboard} />
        <Route exact path="/about" component={About} />
        <Route exact path="/contact" component={Contact} />
</Switch>

App.js

<div className ="App ">
    <div className="contentSection">
        <Navbar/>
        <main id="content">
            <Routes /> 
        </main>
    </div>
</div>

index.js

ReactDOM.render(<Router><App /></Router>, document.getElementById('root'));

Output on My Local

enter image description here

Output on server

enter image description here

1 Answers
Related