How to do routing with material-ui@next MenuItem?

混江龙づ霸主 提交于 2019-12-01 06:41:53

You can use Link as parent component for MenuItem:

  <MenuList>
    <Link to="/myRoute" style={{ textDecoration: 'none', display: 'block' }}>
      <MenuItem>
        go to my route
      </MenuItem>
    </Link>
    <Link to="/anotherRoute" style={{ textDecoration: 'none', display: 'block' }}>
      <MenuItem>
        go to another route
      </MenuItem>
    </Link>
  </MenuList>

Check the working demo (see demo.js file).

you can now give the MenuItem a component prop like this:

<MenuItem component={Link} to='/myRoute'>
go to my route
</MenuItem>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!