Material-ui: can't use Link (from react-router) within MenuItem in 0.14.0-rc2

Created on 23 Dec 2015  路  5Comments  路  Source: mui-org/material-ui

Most helpful comment

Use the containerElement with linkButton props!

see:
http://stackoverflow.com/questions/32106513/material-ui-menu-using-routes/34507786#34507786

<MenuItem
  linkButton
  containerElement={<Link to="/profile" />}
  primaryText="Profile"
  leftIcon={
    <FontIcon className="material-icons">people</FontIcon>
  } />

All 5 comments

MenuItem wraps it's children inside an <a></a> element, hence the error. We'll try to fix it as it causes to many issues. But if you're in a hurry a PR is always welcome ^_^

Well I'm still at 0.13.4 at my project (and I need to release version 0.1 asap - especially that as you can see I'm sitting at christmas eve ;)). after that I might give it a try.
And about well I could expect that - I simply thought that maybe I was using it in improper way.

Merry Christmas anyway :+1:

Use the containerElement with linkButton props!

see:
http://stackoverflow.com/questions/32106513/material-ui-menu-using-routes/34507786#34507786

<MenuItem
  linkButton
  containerElement={<Link to="/profile" />}
  primaryText="Profile"
  leftIcon={
    <FontIcon className="material-icons">people</FontIcon>
  } />

This was fixed with #2708

Another workaround for this issue is to use <LinkContainer> from https://github.com/react-bootstrap/react-router-bootstrap

Was this page helpful?
0 / 5 - 0 ratings