javascript - Change route onClick of div react -


i need wrap navigational component in react in div acts link/a (i have <a></a> nested in nav item , can nest <a></a> within. need re-route user new route on click of outer div acting wrapper. have multiple navigational sections , want use onclick={this.handlenavclick(newroute)} not having success. console logging correct linkpath nothing happens on click.

here function:

  handlenavclick(linkpath) {     console.log(linkpath)     let currentpath = window.location.pathname;     currentpath =  window.location.linkpath;   }, 

here example of me trying re-route 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>         );       }, 

you should try this:

   onclick={() => {this.handlenavclick(dashboardspath)}} 

Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -