Bugs in Sidebar Menu with React Router V4

后端 未结 1 788
天命终不由人
天命终不由人 2021-02-20 17:19

I\'m developing a single-page ReactJS Web app but I know I\'m doing something wrong while defining my routing with React Router V4.

My problem is as follows

相关标签:
1条回答
  • 2021-02-20 18:19

    I found one possible solution here - use the path as the menu keys and provide the location as the selectedKeys:

    <Menu mode="inline" selectedKeys={[location.pathname]}>
      <Menu.Item key="/home">
        <Link to="/home">Home </Link>
      </Menu.Item>
    ...
    

    You can test the solution here

    Hope it helps!

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