Topic: How to programmatically navigate to page with button onClick handler?
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}>
Piotr Glejzer staff answered 5 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>
ultiman answered 5 years ago
OK, but how navigate inside function eventClick, like :
eventClick = () => {
this.props.history.push('/addons');
}
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Answered
- User: 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