Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unknown prop nestedLevel on <a> tag. Remove this prop from the element. #5019

Closed
petersendidit opened this issue Aug 18, 2016 · 5 comments
Closed
Labels
component: list This is the name of the generic UI component, not the React module! v0.x

Comments

@petersendidit
Copy link

petersendidit commented Aug 18, 2016

Problem description

Using react-router's Link with nested ListItems results in a prop warning 'Unknown prop nestedLevel on tag. Remove this prop from the element.'

Steps to reproduce

Use this JSX

<List>
  <ListItem
    primaryText="Inbox"
    initiallyOpen={true}
    nestedItems={[
      <Link to="/starred/">
        <ListItem
          key={1}
          primaryText="Starred"
        />
      </Link>,
      <Link to="/sent/">
        <ListItem
          key={2}
          primaryText="Sent Mail"
        />
      </Link>,
    ]}
  />
</List>

Versions

  • Material-UI: 0.15.4
  • React: 15.3.0
  • react-router: 2.6.1

This is caused by NestedList assuming that the direct children are all ListItems and not ListItems wrapped with a Link. https://github.com/callemall/material-ui/blob/master/src/List/NestedList.js#L39

@oliviertassinari
Copy link
Member

This issue is definitely not limited to the ListItem component. E.g. with the IconMenu one: #4899.
I'm wondering how we could solve it elegantly.

@nikhilmahesh
Copy link

Any Quick fix for this ?

@oliviertassinari
Copy link
Member

oliviertassinari commented Nov 17, 2016

One approach could be to use #4560, but that has proven not to be a great solution (was reverted).
I have just tried the following one of the docs site and it's working just fine:

<ListItem
  primaryText="Get Started"
  primaryTogglesNestedList={true}
  nestedItems={[
    <ListItem
      containerElement={<Link to="/get-started/required-knowledge" />}
      primaryText="Required Knowledge"
      value="/get-started/required-knowledge"
    />,

// ...

Noticed that on the next branch the best pattern would probably to do:

<ListItem
  className={classes.navLink}
  gutters={false}
>
  <Button
    component={Link}
    to={to}
    className={classNames(classes.button, classes.navLinkButton)}
    activeClassName={classes.activeButton}
    ripple={false}
    onClick={this.props.onClick}
  >
    {title}
  </Button>
</ListItem>

@nikhilmahesh
Copy link

containerElement is not working for us but children is working fine. Thanks !

@parthi22
Copy link

parthi22 commented Jul 9, 2017

containerElement worked for me, thanks.

@oliviertassinari oliviertassinari added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Dec 21, 2022
@zannager zannager added component: list This is the name of the generic UI component, not the React module! v0.x and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Jan 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: list This is the name of the generic UI component, not the React module! v0.x
Projects
None yet
Development

No branches or pull requests

5 participants