material-ui icon indicating copy to clipboard operation
material-ui copied to clipboard

not compatible with react-router Link

Open jma7889 opened this issue 11 years ago • 13 comments

I tried to use Link with Menu Item and List Item. Both don't work. As Link is the main navigation for react-router, if it doesn't work, then how can I make -ui work with react-router?

None of the below worked

`<ListItem primaryText="All mail" >
      <Link to="/foo">foo</Link>
</ListItem>`

Then I wrap Link with ListItem, not working neither. Try the same thing with MenuItem, both not working.

-- update 1 It is working now with following syntax. Case can be closed. I wish this is documented. <MenuItem linkButton={true} containerElement={<Link to="/foo" />} primaryText="Foo" />

jma7889 avatar Nov 23 '15 02:11 jma7889

@jma7889 Quite interesting question, but for now I can't see a bug here. Can we discuss on discordapp (Reactiflux/#material-ui) or on gitter?

frankf-cgn avatar Nov 23 '15 07:11 frankf-cgn

@frankf-cgn did see some previous discussion regarding this. About to try if any of those works. Yes, we can discuss on discord app. It's not a bug, more of a feature request.

-- update 1 It is working now with following syntax <MenuItem linkButton={true} containerElement={<Link to="/foo" />} primaryText="Foo" />

jma7889 avatar Nov 23 '15 13:11 jma7889

@jma7889 Otherwise you could just use Navigation mixin:

_handleLink: function(path) {
    this.transitionTo(path);
},
....
<ListItem primaryText="All mail"  onTouchTap={this._handleLink.bind(this, 'mail'}  />

frnk94 avatar Nov 23 '15 21:11 frnk94

Thanks @jma7889. Would be nice if documented.

hourliert avatar Dec 21 '15 01:12 hourliert

Should be fixed by https://github.com/callemall/material-ui/pull/2708.

oliviertassinari avatar Jan 04 '16 18:01 oliviertassinari

@jma7889 If the right-icon-button or some other buttons in a listitem this way, for example:

<ListItem
  rightIconButton={<IconButton />}
  primaryText='some text'
  containerElement={<Link to={{pathname:"/"}} />

These buttons didn't work well.

Dafrok avatar Mar 13 '16 17:03 Dafrok

I think, you made a mistake : try this

<ListItem
  rightIconButton={<IconButton />}
  primaryText='some text'
  containerElement={<Link to="/"/>} />

dahuchao avatar Oct 15 '16 09:10 dahuchao

containerElement with react-router Link works fine with MenuItem but not in ListItem.

Paelsis avatar Jun 21 '17 08:06 Paelsis

@Paelsis This. Wondering if it's going to be fixed.

HZSamir avatar Jun 28 '17 11:06 HZSamir

containerElement with react-router Link for TableRow would be helpful as well.

quasi-nova avatar Oct 17 '17 07:10 quasi-nova

Are there any updates on this? Not even <MenuItem linkButton={true} containerElement={<Link to="/foo" />} primaryText="Foo" /> is working for me.

MarcelRobitaille avatar Mar 01 '18 14:03 MarcelRobitaille

@Iambecomeroot

This is how it worked for me.

 <MenuItem key={i} component={Link} to='/somelink' >
                      {option.primaryText}
</MenuItem>

Source https://stackoverflow.com/a/47875510

iozeey avatar Mar 07 '18 20:03 iozeey

@zeeshan-za-ahmad Working for me. Thanks.

MarcelRobitaille avatar Mar 07 '18 20:03 MarcelRobitaille