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

前端 未结 2 1419
失恋的感觉
失恋的感觉 2021-01-12 23:58

What\'s the best practice to implement routing using the material-ui@next? In the previous version I could use containerElement with a Link

相关标签:
2条回答
  • 2021-01-13 00:42

    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>
    
    0 讨论(0)
  • 2021-01-13 00:44

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

    <MenuItem component={Link} to='/myRoute'>
    go to my route
    </MenuItem>
    
    0 讨论(0)
提交回复
热议问题