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

Incorrect prop types on ListboxButton #929

Open
afk-mario opened this issue Jun 2, 2022 · 2 comments
Open

Incorrect prop types on ListboxButton #929

afk-mario opened this issue Jun 2, 2022 · 2 comments

Comments

@afk-mario
Copy link

afk-mario commented Jun 2, 2022

🐛 Bug report

Current Behavior

Getting the following error:

**Warning: Failed prop type: Invalid prop `arrow` supplied to `ListboxButton`, expected one of type [boolean].**

And this is how I'm using the Listbox

function Listbox({ options, className, ...rest }) {
  const customClassName = classnames(`${classNamePrefix}`, className);

  return (
    <ListboxInput className={customClassName} {...rest}>
      <ListboxButton
        className={`${classNamePrefix}-button`}
        arrow={() => <CgChevronDown />}
      />
      <ListboxPopover className={`${classNamePrefix}-popover`}>
        <ListboxList className={`${classNamePrefix}-list`}>
          {options.map(({ value, label }) => {
            return (
              <ListboxOption
                key={value}
                value={value}
                className={`${classNamePrefix}-option`}
              >
                {label}
              </ListboxOption>
            );
          })}
        </ListboxList>
      </ListboxPopover>
    </ListboxInput>
  );
}

Expected behavior

Listbox Button accepts a boolean or node

Reproducible example

https://codesandbox.io/s/hidden-rain-mbovdk?file=%2Fsrc%2Findex.js

@jonrutter
Copy link

Hi @afk-mario! I think this is an issue with your code. The component expects arrow to be a boolean or node, and you are passing it a function. It should work correctly if you pass it the icon directly:

<ListboxButton
  className={`${classNamePrefix}-button`}
  arrow={<CgChevronDown />}
/>

Here's a sandbox of a working example: https://codesandbox.io/s/charming-brahmagupta-emibiv?file=/src/index.js

@afk-mario
Copy link
Author

afk-mario commented Jun 28, 2022

The component expects arrow to be a boolean or node,

You are right! I missed it I think I did because the error is

Warning: Failed prop type: Invalid prop `arrow` supplied to `ListboxButton`, expected one of type [boolean].

instead of

[Warning: Failed prop type: Invalid prop `arrow` supplied to `ListboxButton`, expected one of type [boolean, node].

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

2 participants