Skip to content

@ionic/react Conditional rendering of IonTabButton throws exception #17778

Closed

Description

@Nasicus

Bug Report

Ionic version:
[x] 4.x (@ionic/react: 0.0.5)

If you add anything other than an IonTabButton within a IonTabBar you'll get an exception.
Even simple conditional stuff like this....

{false && (
  <IonTabButton tab="schedule" href="/schedule">
    <IonIcon name="calendar" />
    <IonLabel>Schedule</IonLabel>
  </IonTabButton>
)}

... will result in the exception:

TypeError: Cannot read property 'type' of null

@ionic/react/dist/components/navigation/IonTabBar.js
  38 | 
  39 | var tabActiveUrls = {};
  40 | React.Children.forEach(_this.props.children, function (child) {
> 41 |   if (typeof child === 'object' && child.type === IonTabButton) {
  42 | ^   tabActiveUrls[child.props.tab] = {
  43 |       originalHref: child.props.href,
  44 |       currentHref: child.props.href

Activity

  1. self-assigned this
    on Mar 22, 2019
  2. added
    package: react
    on Mar 22, 2019
  3. jthoms1 commented on Mar 22, 2019

    @jthoms1
    Contributor

    Will be available in the next release.

  4. ionitron-bot commented on Apr 21, 2019

    @ionitron-bot

    Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.

  5. locked and limited conversation to collaborators on Apr 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

package: react

Type

No type

Fields

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