Holiday Notice: Support will be provided on a limited scale from December 24th, 2024, to January 2nd, 2025. Happy holidays and a wonderful New Year!


Topic: How to programmatically navigate to page with button onClick handler?

ultiman free asked 4 years ago


I have Navbar and Routes defined but I need to navigate with button onClick handler?

<MDBBtn type="button"  className="btn-block z-depth-2" onClick={this.handleClick}>

ultiman free answered 4 years ago


OK, but how navigate inside function eventClick, like :

  eventClick = () => {
    this.props.history.push('/addons');
}

Piotr Glejzer staff answered 4 years ago


You can use Link/NavLink component like a button or use these components like wrappers to button and add a click event handler to Link.

                 <MDBNavLink
                    tag='button'
                    to='/addons'
                    color='mdb-color'
                    className='btn btn-outline-mdb-color btn-sm btn-rounded d-inline'
                    onClick={this.eventClick}
                  >
                    More
                  </MDBNavLink>


Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Answered

Specification of the issue

  • ForumUser: Free
  • Premium support: No
  • Technology: MDB React
  • MDB Version: 4.25.6
  • Device: PC
  • Browser: Chrome
  • OS: Windows 10
  • Provided sample code: No
  • Provided link: No