I need to wrap a navigational component in React in a div that acts as a link/a (I have an <a></a>
nested in the nav item already and can nest another <a></a>
within. I need re-route the user to a new route on click of this outer most div that is acting as a wrapper. I have multiple navigational sections and want to use something like an onClick={this.handleNavClick(newRoute)}
but am not having any success. I am console logging the correct linkPath but nothing happens on click.
Here is my function:
handleNavClick(linkPath) {
console.log(linkPath)
let currentPath = window.location.pathname;
currentPath = window.location.linkPath;
},
Here is an example of me trying to re-route from a nav section:
getNavItem() {
const currentPath = window.location.pathname;
const reportPath = "/reporting";
return (
<div onClick={this.handleNavClick(dashboardsPath)}>
<li id="nav-item-view" className={ classNames({"active": currentPath === reportPath}, "sidebar-item")}>
<div className="active-carat"></div>
</li>
</div>
);
},