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

[Tabs] Conditional rendering of Tab fails #8093

Closed
hongyuan1306 opened this issue Sep 8, 2017 · 1 comment
Closed

[Tabs] Conditional rendering of Tab fails #8093

hongyuan1306 opened this issue Sep 8, 2017 · 1 comment
Assignees
Labels
component: tabs This is the name of the generic UI component, not the React module! good first issue Great for first contributions. Enable to learn the contribution process. new feature New feature or request

Comments

@hongyuan1306
Copy link
Contributor

Normally I would expect the following conditional rendering to work:

    <Tabs value="tab2" indicatorColor="accent" textColor="accent">
      {false && <Tab label="Tab 1" value="tab1"/>}
      <Tab label="Tab 2" value="tab2" />
      <Tab label="Tab 3" value="tab3" />
    </Tabs>

This is a very common idiom in react. However with Tabs component I get this:

Tabs.js:349 Uncaught TypeError: Cannot read property 'props' of null
    at Tabs.js:349
    at mapSingleChildIntoContext (ReactChildren.js:107)
    at traverseAllChildrenImpl (traverseAllChildren.js:77)
    at traverseAllChildrenImpl (traverseAllChildren.js:93)
    at traverseAllChildren (traverseAllChildren.js:172)
    at mapIntoWithKeyPrefixInternal (ReactChildren.js:127)
    at Object.mapChildren [as map] (ReactChildren.js:149)
    at Tabs.render (Tabs.js:348)
    at ReactCompositeComponent.js:795
    at measureLifeCyclePerf (ReactCompositeComponent.js:75)

See example https://codesandbox.io/s/61j57j339w

Is this a bug or that in material-ui we can not use this form of conditional rendering in container components?

| Material-UI | 1.0.0-beta.8 |

@oliviertassinari oliviertassinari added component: table This is the name of the generic UI component, not the React module! component: tabs This is the name of the generic UI component, not the React module! good first issue Great for first contributions. Enable to learn the contribution process. new feature New feature or request and removed component: table This is the name of the generic UI component, not the React module! labels Sep 8, 2017
@oliviertassinari
Copy link
Member

This is something we could be supporting 👍.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: tabs This is the name of the generic UI component, not the React module! good first issue Great for first contributions. Enable to learn the contribution process. new feature New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants