react button onClick redirect page

前端 未结 13 2236
我在风中等你
我在风中等你 2020-12-02 15:19

I am working on web application using React and bootstrap. When it comes to applying button onClick, it takes me hard time to let my page being redirect to another. if afte

相关标签:
13条回答
  • 2020-12-02 16:02

    I was also having the trouble to route to a different view using navlink.

    My implementation was as follows and works perfectly;

    <NavLink tag='li'>
      <div
        onClick={() =>
          this.props.history.push('/admin/my- settings')
        }
      >
        <DropdownItem className='nav-item'>
          Settings
        </DropdownItem>
      </div>
    </NavLink>
    

    Wrap it with a div, assign the onClick handler to the div. Use the history object to push a new view.

    0 讨论(0)
提交回复
热议问题