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

0 value not displaying in DropdownToggle #1496

Closed
tagyoureit opened this issue May 21, 2019 · 3 comments
Closed

0 value not displaying in DropdownToggle #1496

tagyoureit opened this issue May 21, 2019 · 3 comments

Comments

@tagyoureit
Copy link

  • components: DropdownToggle
  • reactstrap version #8.0.0
  • import method umd/csj/es es
  • react version #16.8.6
  • bootstrap version #4.0.0

What is happening?

I'm passing props to a custom component that sometimes has the value of 0. The render in my custom file looks like this:

    return (
      <div>
        <ButtonDropdown isOpen={this.state.dropdownOpen} toggle={this.toggleDropDown} disabled={this.state.disabled} >
          <DropdownToggle caret disabled={this.state.disabled}>
            {this.props.currentMinute}
          </DropdownToggle>
          <DropdownMenu>
            {positions()}
          </DropdownMenu>
        </ButtonDropdown>
      </div >
    )

When the value of currentMinute=0 the display shows this:
2019-05-20_21-17-49
(In the yellow box the 0 comes from the parent file.)

What should be happening?

0 should be displayed as a value just like the other values (

Steps to reproduce issue

It appears that reactstrap is treating this 0 as a boolean value. If I change the code to display based on an if/else {this.props.currentMinute === 0 ? '0' : this.props.currentHour} it does display properly.

2019-05-20_21-25-24

Interestingly, it seems if I put any other code as a child here it does render properly. For example, {this.props.currentMinute}{'anything else'} will show 0anything else.

Error message in console

No error

Code

https://stackblitz.com/edit/react-7zzcjw

@TheSharpieOne
Copy link
Member

TheSharpieOne commented May 21, 2019

Probably due to

const children = props.children || <span className="sr-only">{ariaLabel}</span>;

For now, you can just use this.props.currentMinute.toString() or something like <span>{this.props.currentMinute}</span>

@tagyoureit
Copy link
Author

Thanks. I settled on {this.props.currentMinute}{''} for now and it is working fine.

TheSharpieOne added a commit that referenced this issue Jun 22, 2020
Co-authored-by: Evan Sharp <dumbdrum@gmail.com>
@kyletsang
Copy link
Member

Closing as fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants