Skip to content

Error when conditionally generating Tabs and TabPanels #37

@sgronblo

Description

@sgronblo

If you use a ternary condition to return a null instead of a Tab react-tabs you get a "Uncaught TypeError: Cannot read property 'ref' of null".

Example

<div>
  <Tabs>
    { shouldShowTabA ? <Tab>Tab A</Tab> : null }
    { shouldShowTabB ? <Tab>Tab B</Tab> : null }
  </Tabs>
  { shouldShowTabA ? <TabPanel>{contentForA}</TabPanel> : null }
  { shouldShowTabB ? <TabPanel>{contentForB}</TabPanel> : null }
</div>

The assumption here is of course that at least one of the tabs will be displayed. I am not sure what will happen if you don't define any Tab elements.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions