I´m trying to build a Boostrap 4 NavBar that will use ReactJS <Link> component from react-router instead of the original <li> class.
Currently I´m having troubles building the component correctly, as at the end the ReactJS component has not the expected behaviour.
Let´s start from the original Boostrap 4 NavBar example:
<nav class="navbar navbar-toggleable-md navbar-light bg-faded">
<button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<a class="navbar-brand" href="#">Navbar</a>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto">
<li class="nav-item active">
<a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link disabled" href="#">Disabled</a>
</li>
</ul>
<form class="form-inline my-2 my-lg-0">
<input class="form-control mr-sm-2" type="text" placeholder="Search">
<button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
</form>
</div>
</nav>
This is being migrated to a ReactJS component as the following:
import React from 'react';
import Link from 'react-router-dom/Link';
function Menu() {
return (
<div>
<nav className="navbar navbar-toggleable-md navbar-light bg-faded">
<button className="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span className="navbar-toggler-icon"></span>
</button>
<a className="navbar-brand" href="#">Navbar</a>
<div className="collapse navbar-collapse" id="navbarSupportedContent">
<ul className="navbar-nav mr-auto">
<span className="nav-item active">
<Link className="nav-link" to="/">Home <span className="sr-only">(current)</span></Link>
</span>
<span className="nav-item">
<Link className="nav-link" to="/counter">Counter</Link>
</span>
<span className="nav-item">
<Link className="nav-link disabled" to="/about">About</Link>
</span>
</ul>
<form className="form-inline my-2 my-lg-0">
<input className="form-control mr-sm-2" type="text" placeholder="Search" />
<button className="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
</form>
</div>
</nav>
</div>
);
}
export default Menu;
Altough it runs, many of the formatting is lost and some features like "nav-link disabled" are not working (you can click on About and it goes to the desired page).
I´m sure I´m doing the conversion wrong, so help is appreciated here to fix the component code so that to reflect correctly the original behaviour without React.
Maybe you got it resolved. Here's a working example with Bootstrap 4:
import React from 'react';
import { render } from 'react-dom';
import { BrowserRouter, Route, Switch, Link } from 'react-router-dom';
const AppPage = () => <h1>React Router 4 & Bootstrap 4</h1>
const HomePage = () => <h1>Welcome Home !</h1>
const AboutPage = () => <h1>About Us</h1>
const OneMorePage = () => <h1>One More Page !</h1>
const PrimaryLayout = () => (
<div>
<nav className="navbar navbar-expand-md navbar-dark bg-dark">
<Link className="navbar-brand" to="/">App</Link>
<button type="button" className="navbar-toggler" data-toggle="collapse" data-target="#navbarNav">
<span className="navbar-toggler-icon"></span>
</button>
<div className="collapse navbar-collapse" id="navbarNav">
<ul className="navbar-nav mr-auto">
<li className="nav-item"><Link className="nav-link" to="/home">Home</Link></li>
<li className="nav-item"><Link className="nav-link" to="/about">About</Link></li>
<li className="nav-item"><Link className="nav-link" to="/one">More</Link></li>
</ul>
</div>
</nav>
<div className="container-fluid">
<Switch>
<Route path="/" exact component={AppPage} />
<Route path="/home" component={HomePage} />
<Route path="/about" component={AboutPage} />
<Route path="/one" component={OneMorePage} />
</Switch>
</div>
</div>
)
const App = () => (
<BrowserRouter>
<PrimaryLayout />
</BrowserRouter>
)
render(<App />, document.getElementById('root'))
For this particular use case, there's an easy solution.
Simply add this to your css:
.nav-link.disabled { pointer-events: none }.
That said, I'd strongly recommend to use a library of bootstrap-based react components on the long term. I personally like https://reactstrap.github.io/.
The problem is Bootstrap has a Javascript component as well which will not work in React as it clashes with React's Javascript. The CSS portion works which is what you are seeing.
You should use something like React-Bootstrap- https://react-bootstrap.github.io/. These are all the Bootstrap components written as React components so you can use them in the standard React manner by importing and using them in your JSX.
Related
I'm having a hard time understanding how the routes and outlets work in react. My problem is this.
If I have a route that should load 3 parts.
-Top Menu
-Side Menu
-Center Content
But the center content is contained in the div thats wrapped by the "Side Menu" how do I wrap another element that will be changing inside of a previous component. My goal is to use the first 2 in all of the routes and based on the route the center content will change.
This is what it should look like
<div id="layoutSideNav">
<div id="layoutsidenav_nav"></div>
<div id="layoutSidenav_content"></div>
</div>
But for some reason all I can get is this
<div id="layoutSideNav">
<div id="layoutsidenav_nav"></div>
</div>
<div id="layoutSidenav_content"></div>
My react looks like this.
3 Components
Contains the top nav
contains the side nav
contains body elements that will change.
App()
<Route
path='/admin-dashboard'
element={
<>
<AdminNavigation />
<AdminNavigationLeft />
<AdminDashBoardHome />
</>
}
>
If I add <Outlet/> before the closing div in "layoutSideNav" component. nothing happens. If I remove the outlets from all components the app() looks the same. The top nav and side nave display correclty, but the center content is wonky.
I feel like routes is so much more abstract than I'm used to so maybe I'm just not thinking about it logically. Thank you so much for your help!
I tried using <Outlet/> to adjust how where the third component content displayed.
I've added my full code below for review.
const AdminNavigation = () =>{
const toggleSideMenu = event => {
// 👇️ toggle class on click
document.getElementsByTagName('body')[0].classList.toggle('sb-sidenav-toggled');
};
return (
<Fragment>
<nav className="sb-topnav navbar navbar-expand navbar-dark bg-dark">
<a className="navbar-brand ps-3" href="index.html">Woodmoore Improvement</a>
<button className="btn btn-link btn-sm order-1 order-lg-0 me-4 me-lg-0" onClick={toggleSideMenu} id="sidebarToggle" href="#!"><i className="fas fa-bars"></i></button>
<form className="d-none d-md-inline-block form-inline ms-auto me-0 me-md-3 my-2 my-md-0">
<div className="input-group">
<input className="form-control" type="text" placeholder="Search for..." aria-label="Search for..." aria-describedby="btnNavbarSearch" />
<button className="btn btn-primary" id="btnNavbarSearch" type="button"><i className="fas fa-search"></i></button>
</div>
</form>
<ul className="navbar-nav ms-auto ms-md-0 me-3 me-lg-4">
<li className="nav-item dropdown">
<a className="nav-link dropdown-toggle" id="navbarDropdown" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false"><i className="fas fa-user fa-fw"></i></a>
<ul className="dropdown-menu dropdown-menu-end" aria-labelledby="navbarDropdown">
<li><a className="dropdown-item" href="#!">Settings</a></li>
<li><hr className="dropdown-divider" /></li>
<li><a className="dropdown-item" href="#!">Logout</a></li>
</ul>
</li>
</ul>
</nav>
</Fragment>
)
}
export default AdminNavigation;
const AdminDashBoardHome = () => {
return(
<Fragment>
<div id='layoutSidenav_content'>
<main>
<div className='container-fluid px-4'>
<h1 className='mt-4'>HOA Member Manager</h1>
<ol className='breadcrumb mb-4'>
<li className='breadcrumb-item active'>Member Map</li>
</ol>
<div className='row'>
<div className='col-lg-12'>
<div className='embed-responsive embed-responsive-16by9'>
<div id='map_canvas' className='embed-responsive-item pb-4' >
</div>
</div>
</div>
</div>
<div className='row'>
</div>
<div className='card mb-4'>
<div className='card-header'>
<i className='fas fa-table me-1'></i>
Member Lookup
</div>
<MemberDataList/>
</div>
</div>
</main>
<footer className='py-4 bg-light mt-auto'>
<div className='container-fluid px-4'>
<div className='d-flex align-items-center justify-content-between small'>
<div className='text-muted'>Copyright © Your Website 2022</div>
<div>
<a href='#'>Privacy Policy</a>
·
<a href='#'>Terms & Conditions</a>
</div>
</div>
</div>
</footer>
</div>
</Fragment>
)
}
export default AdminDashBoardHome;
const AdminNavigationLeft = () => {
document.body.classList.add('sb-nav-fixed');
return(
<Fragment>
<div id="layoutSidenav">
<Outlet/>
<div id="layoutSidenav_nav">
<nav className="sb-sidenav accordion sb-sidenav-dark" id="sidenavAccordion">
<div className="sb-sidenav-menu">
<div className="nav">
<div className="sb-sidenav-menu-heading">Core</div>
<a className="nav-link" href="index.html">
<div className="sb-nav-link-icon"><i className="fas fa-tachometer-alt"></i></div>
Dashboard
</a>
<div className="sb-sidenav-menu-heading">Interface</div>
<a className="nav-link collapsed" href="#" data-bs-toggle="collapse" data-bs-target="#collapseLayouts" aria-expanded="false" aria-controls="collapseLayouts">
<div className="sb-nav-link-icon"><i className="fas fa-columns"></i></div>
Layouts
<div className="sb-sidenav-collapse-arrow"><i className="fas fa-angle-down"></i></div>
</a>
<div className="collapse" id="collapseLayouts" aria-labelledby="headingOne" data-bs-parent="#sidenavAccordion">
<nav className="sb-sidenav-menu-nested nav">
<a className="nav-link" href="layout-static.html">Static Navigation</a>
<a className="nav-link" href="layout-sidenav-light.html">Light Sidenav</a>
</nav>
</div>
<a className="nav-link collapsed" href="#" data-bs-toggle="collapse" data-bs-target="#collapsePages" aria-expanded="false" aria-controls="collapsePages">
<div className="sb-nav-link-icon"><i className="fas fa-book-open"></i></div>
Admin Management
<div className="sb-sidenav-collapse-arrow"><i className="fas fa-angle-down"></i></div>
</a>
<div className="collapse" id="collapsePages" aria-labelledby="headingTwo" data-bs-parent="#sidenavAccordion">
<nav className="sb-sidenav-menu-nested nav accordion" id="sidenavAccordionPages">
<a className="nav-link collapsed" href="#" data-bs-toggle="collapse" data-bs-target="#pagesCollapseAuth" aria-expanded="false" aria-controls="pagesCollapseAuth">
Manage Users
</a>
<a className="nav-link collapsed" href="#" data-bs-toggle="collapse" data-bs-target="#pagesCollapseAuth" aria-expanded="false" aria-controls="pagesCollapseAuth">
Create New
</a>
</nav>
</div>
</div>
</div>
<div className="sb-sidenav-footer">
<div className="small">Logged in as:</div>
Start Bootstrap
</div>
</nav>
</div>
</div>
</Fragment>
)
}
export default AdminNavigationLeft;
If the following is what you intend to be rendered:
<div id="layoutSideNav">
<div id="layoutsidenav_nav"></div>
<div id="layoutSidenav_content"></div>
</div>
Then I suspect you want the routed content to be rendered in the layoutSidenav_content div. Something like the following:
<div id="layoutSideNav">
<div id="layoutsidenav_nav">
... navbar content ...
</div>
<div id="layoutSidenav_content">
... routed content ...
</div>
</div>
In other words, the above snippet describes a layout component, the routed content is the logical place for an Outlet component wrapping nested routes to output their element content into. The route may look like:
const AdminLayout = () => (
<>
<AdminNavigation />
<div id="layoutsidenav">
<div id="layoutSidenav_nav">
<AdminNavigationLeft />
</div>
<div id="layoutsidenav_content">
<Outlet />
</div>
</div>
</>
);
<Route
path='/admin-dashboard'
element={<AdminLayout />}
>
<Route index element={<AdminDashBoardHome />} />
... other admin routes
</Route>
const AdminNavigationLeft = () => {
useEffect(() => {
document.body.classList.add('sb-nav-fixed');
}, []);
return (
<nav className="sb-sidenav accordion sb-sidenav-dark" id="sidenavAccordion">
<div className="sb-sidenav-menu">
...
</div>
</nav>
)
}
const AdminDashBoardHome = () => {
return (
<Fragment>
<main>
...
</main>
<footer className='py-4 bg-light mt-auto'>
...
</footer>
</Fragment>
)
}
I solved my own question.
You need to run the props through the component you're trying to display. The solution should be like this.
App()
<Route path='/admin-dashboard' element={<><AdminNavigation /><AdminNavigationLeft><AdminDashBoardHome/></AdminNavigationLeft></>}>
AdminDashLeft()
const AdminNavigationLeft = (props) => {
{props.children} // This is where the child component should display
}
I have this bootstrap NavBar that works perfectly with "a", but when I try to replace the "a" with "Link" from React it pretty much breaks the app, the Navbar stops showing. Is it because of the Bootstrap? I saw a video from youtube that this works, maybe with newer versions this doesn't work?
import React from "react";
import { Link } from "react-router-dom";
<nav className="navbar navbar-expand-lg navbar-light bg-light">
<div className="container-fluid">
<div>
<img width="100" src="/assets/images/logo.jpg"></img>
</div>
<button
className="navbar-toggler"
type="button"
data-bs-toggle="collapse"
data-bs-target="#navbarSupportedContent"
aria-controls="navbarSupportedContent"
aria-expanded="false"
aria-label="Toggle navigation"
>
<span className="navbar-toggler-icon"></span>
</button>
<div className="collapse navbar-collapse" id="navbarSupportedContent">
<ul className="navbar-nav me-auto mb-2 mb-lg-0">
<li className="nav-item">
<Link className="nav-link" to="/">Home</Link> <----------------here for ex.
</li>
<li className="nav-item">
<a className="nav-link active" aria-current="page" href="#">
Productos
</a>
</li>
<li className="nav-item">
<a className="nav-link active" aria-current="page" href="#">
Nosotros
</a>
</li>
<li className="nav-item">
<a className="nav-link active" aria-current="page" href="#">
Contacto
</a>
</li>
</ul>
</div>
</div>
</nav>
Judging from the href attribute in your <a> components, I believe you are trying to access a component on the same page using hashes.
Link from react-router-dom does not actually support this feature from what I know. Instead, I suggest installing react-router-hash-link which supports it.
The import can look like
import { HashLink as Link } from 'react-router-hash-link';
And you can have the same component attributes
<li className="nav-item">
<Link className="nav-link active" aria-current="page" to="/#productos">
Productos
</Link>
</li>
You need to enclose your <NavLink/>, <Link/>, <Routes/> and <Route/> components with a Router like <BrowserRouter/>.
So in App.js or another top level component, you need to do it like this:
const App = (props) => {
<BrowserRouter>
<Your sidebar component including NavLink elements/>
<Your app module including Route elements/>
</BrowserRouter>
}
I have made a Navbar which is made using Bootstrap, it's not full width, Here is the image
I have tried adding nav-fill w-100 class but it didn't worked, Here is my Navbar.js code
import React from 'react'
import PropTypes from 'prop-types'
import { Link } from 'react-router-dom';
export default function Navbar(props) {
return (
<nav className={`navbar navbar-expand-lg navbar-${props.mode} bg-${props.mode} `}>
<div className="container-fluid ">
<Link className="navbar-brand" to="/">{props.title}</Link>
<button className="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span className="navbar-toggler-icon"></span>
</button>
<div className="collapse navbar-collapse" id="navbarSupportedContent">
<ul className="navbar-nav me-auto mb-2 mb-lg-0 ">
<li className="nav-item">
<Link className="nav-link" aria-current="page" to="/">Home</Link>
</li>
<li className="nav-item">
<Link className="nav-link" to="/about">{props.aboutText}</Link>
</li>
</ul>
<div className={`form-check form-switch text-${props.mode==='light'?'dark':'light'}`}>
<input className="form-check-input" onClick={props.toggleMode} type="checkbox" id="flexSwitchCheckDefault"/>
<label className="form-check-label" htmlFor="flexSwitchCheckDefault">Enable DarkMode</label>
</div>
</div>
</div>
</nav>
)
}
Navbar.propTypes = {
title: PropTypes.string.isRequired,
aboutText: PropTypes.string.isRequired
}
Navbar.defaultProps = {
title: 'Set title here',
aboutText: 'About'
};
You can use vw instead of %. When you're using width it will take 100% of the parents width. However when you want to use the width of the view you can just
.navbar{
width: 100vw!important;
}
Sorry if the title is kinda confusing.
I'm making an index page with a side and top navbar with the menu using react router, I have successfully loaded the content up but I want it to load in the main body, the middle of the page.
I've tried separating method like how I used JSP before but its not very effective so to speak
import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import Login from './Login';
import * as serviceWorker from './serviceWorker';
import Dropdown from 'react-bootstrap/Dropdown';
import { Link } from 'react-router-dom';
import { BrowserRouter, Route } from "react-router-dom";
import './index.css';
import AssetView from './AssetView';
import DepartmentView from './DepartmentView';
import LocationView from './LocationView';
import EmployeeView from './EmployeeView';
import AddDepartment from './AddDepartment';
import AddLocation from './AddLocation';
const routing = (
<BrowserRouter>
<div>
<nav class="navbar navbar-dark fixed-top bg-dark flex-md-nowrap p-0">
<a class="navbar-brand col-sm-3 col-md-2 mr-0" href="#">Company name</a>
<ul class="navbar-nav px-3">
<li class="nav-item dropdown">
<Dropdown>
<Dropdown.Toggle variant="success" id="dropdown-basic">
Account
</Dropdown.Toggle>
<Dropdown.Menu>
<Dropdown.Item href="#/action-1">Informations</Dropdown.Item>
<Dropdown.Item href="#/action-2">Settings</Dropdown.Item>
<Dropdown.Item href="#/action-3">Signout</Dropdown.Item>
</Dropdown.Menu>
</Dropdown>
</li>
</ul>
</nav>
<div class="container-fluid">
<div class="row">
<nav class="col-md-2 d-none d-md-block bg-light sidebar">
<div class="sidebar-sticky">
<ul class="nav flex-column">
<li class="nav-item">
<a class="nav-Link active" href="#">
<span data-feather="home"></span>
Dashboard <span className="sr-only">(current)</span>
</a>
</li>
<h6 className="sidebar-heading d-flex justify-content-between align-items-center px-3 mt-4 mb-1 text-muted">
<span>Assets Management</span>
<a className="d-flex align-items-center text-muted" href="#">
<span data-feather="plus-circle" />
</a>
</h6>
<li className="nav-item">
<Link to="/AssetView">
<a class="nav-link" href="#">
<span data-feather="file"></span>
View All Assets
</a>
</Link>
</li>
</ul>
<h6 className="sidebar-heading d-flex justify-content-between align-items-center px-3 mt-4 mb-1 text-muted">
<span>Company Management</span>
<a className="d-flex align-items-center text-muted" href="#">
<span data-feather="plus-circle" />
</a>
</h6>
<ul className="nav flex-column mb-2">
<li className="nav-item">
<Link to="/DepartmentView">
<a class="nav-link" href="#">
<span data-feather="file"></span>
View All Departments
</a>
</Link>
</li>
<li className="nav-item">
<Link to="/AddDepartment">
<a class="nav-link" href="#">
<span data-feather="file"></span>
Add New Department
</a>
</Link>
</li>
<li className="nav-item">
<Link to="/LocationView">
<a class="nav-link" href="#">
<span data-feather="file"></span>
View All Locations
</a>
</Link>
</li>
<li className="nav-item">
<Link to="/AddLocation">
<a class="nav-link" href="#">
<span data-feather="file"></span>
Add New Location
</a>
</Link>
</li>
</ul>
<h6 className="sidebar-heading d-flex justify-content-between align-items-center px-3 mt-4 mb-1 text-muted">
<span>Employees Management</span>
<a className="d-flex align-items-center text-muted" href="#">
<span data-feather="plus-circle" />
</a>
</h6>
<ul className="nav flex-column mb-2">
<li className="nav-item">
<Link to="/EmployeeView">
<a class="nav-link" href="#">
<span data-feather="file"></span>
View All Employees
</a>
</Link>
</li>
</ul>
</div>
</nav>
</div>
</div>
<Route exact path="/AssetView" component={AssetView} />
<Route path="/DepartmentView" component={DepartmentView} />
<Route path="/LocationView" component={LocationView} />
<Route path="/EmployeeView" component={EmployeeView} />
<Route path="/AddDepartment" component={AddDepartment} />
<Route path="/AddLocation" component={AddLocation} />
</div>
</BrowserRouter>
)
ReactDOM.render(routing, document.getElementById('root'));
serviceWorker.unregister();
This is how the page looks right now, I really wish to make the content of the page appear in the middle
https://photos.app.goo.gl/BSuZuvGhiQQetmit5
You mean, you have to create a dashboard-like app
Where top and sidebar is static and on click of the sidebar the middle part change
Then you can check this repo
https://github.com/designrevision/shards-dashboard-react
Here is the master page https://github.com/DesignRevision/shards-dashboard-react/blob/master/src/layouts/Default.js
import React from "react";
import PropTypes from "prop-types";
import { Container, Row, Col } from "shards-react";
import MainNavbar from "../components/layout/MainNavbar/MainNavbar";
import MainSidebar from "../components/layout/MainSidebar/MainSidebar";
import MainFooter from "../components/layout/MainFooter";
const DefaultLayout = ({ children, noNavbar, noFooter }) => (
<Container fluid>
<Row>
<MainSidebar />
<Col
className="main-content p-0"
lg={{ size: 10, offset: 2 }}
md={{ size: 9, offset: 3 }}
sm="12"
tag="main"
>
{!noNavbar && <MainNavbar />}
{children}
{!noFooter && <MainFooter />}
</Col>
</Row>
</Container>
);
DefaultLayout.propTypes = {
/**
* Whether to display the navbar, or not.
*/
noNavbar: PropTypes.bool,
/**
* Whether to display the footer, or not.
*/
noFooter: PropTypes.bool
};
DefaultLayout.defaultProps = {
noNavbar: false,
noFooter: false
};
export default DefaultLayout;
The correct answer has been replied by #ravibagul91, thank you.
I removed the class="sidebar-sticky" of the sidebar and add the .sidebar{position:absolute;top:0;bottom:0} in my index.css and it works just fine as the image I just uploaded
https://photos.app.goo.gl/m744U7R4mACAUXq37
Thank you #piyush-dhamecha for the recommendation, it is somewhat similar to what I need, but truth be told, it's still kinda advance for me, but I appreciate it and will keep it for future reference.
The NavLink of react router does not route to the appropriate page when the Navlink reside in the dropdown.
Below the Html struture tried to implement in React
<BrowserRouter>
<header className="menubar">
<nav className="navbar navbar-expand-sm">
<button className="navbar-toggler" data-toggle="collapse" data-target="#menu">
<span className="navbar-toggler-icon"></span>
</button>
<div className="collapse navbar-collapse" id="menu">
<ul className="navbar-nav">
<li className="nav-item">
<div className="dropdown" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" id="loanlink">
<a href="#!" className="nav-link dropdown-toggle">
<span className="menuTitle">Loan</span>
</a>
<div className="dropdown-menu dropdown-menu-center" aria-labelledby="loanlink">
<div className="menuPointer"></div>
<NavLink className="dropdown-item" to="/loan">
<div className="menuContent">
<span className="menuTitle">Manage Loan</span>
</div>
</NavLink>
</div>
</div>
</li>
<li className="nav-item">
<NavLink className="nav-link dropdown-toggle" to="/revenue" >
<span className="menuTitle">Revenue</span>
</NavLink>
</li>
</ul>
</div>
</nav>
</header>
</BrowserRouter>
In the above code, the "revenue" link which is not dropdown-menu is working fine, but the links which are inside dropdown-menu is not working.
I think the dropdown toggle event prevents the react router navigation.
Am using React router and Bootstrap 4 (not reactstrap)
This is a late answer, but the problem is that Bootstrap's data-toggle for the Dropdown is preventing the route from working.
You can solve it by toggling the Dropdown using React state, instead of using the data-toggle behavior in Bootstrap.
<li className="nav-item">
<div className="dropdown" display="static" onClick={this.handleClick}>
<a href="#!" className="nav-link dropdown-toggle">
<span className="menuTitle">Loan</span>
</a>
<div className={this.state.showDD?'dropdown-menu show':'dropdown-menu'}>
<NavLink className="dropdown-item" to="/loan">
<span>Manage Loan</span>
</NavLink>
</div>
</div>
</li>
https://codeply.com/p/auvCgEmeiD