8

What's the best practice to implement routing using the material-ui@next? In the previous version I could use containerElement with a Link but doesn't work anymore. Couldn't find any help in the docs.

 <MenuItem containerElement={<Link to="/myRoute" />}>My Link</MenuItem>
Mikhail Shabrikov
  • 8,453
  • 1
  • 28
  • 35
Bryan Stump
  • 1,419
  • 2
  • 17
  • 26

2 Answers2

16

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

<MenuItem component={Link} to='/myRoute'>
go to my route
</MenuItem>
mrbenbot
  • 171
  • 1
  • 3
11

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>
Mikhail Shabrikov
  • 8,453
  • 1
  • 28
  • 35