couds / react-bulma-components

React components for Bulma framework
MIT License
1.21k stars 126 forks source link

Warning: Failed prop type: Invalid prop `value` supplied to `Select` #286

Closed 1r3n33 closed 3 years ago

1r3n33 commented 3 years ago

Hello,

I'm experiencing a warning with Select when multiple prop is true. Can you confirm this issue?

Bug description

I get a warning when I use Select with the multiple prop and pass an array to value prop:

<Select multiple={true} value={[]} onChange={()=>{}}>
  <option key='1' value='1'>One</option>
  <option key='2' value='2'>Two</option>
</Select>
Warning: Failed prop type: Invalid prop `value` supplied to `Select`

To Reproduce

  1. Instantiate Select with multiple={true} and value={[]}
  2. See warning in developer tools console

Expected behavior

No warning.

Versions

Additional context

I have fixed the issue locally by changing the value constraint in Select.js:

value: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.string, PropTypes.number]))]),

I am willing to create a pull request in the next branch so it can be fixed for 4.0 (I can also do a pull request for 3.4.0).

What do you think?

kennethnym commented 3 years ago

Will look into this. Thank you for reporting.

Edit: sorry, yes if you're able to make a PR that would be great. I'll review it asap.

kennethnym commented 3 years ago

Should be fixed in 2ea2ced4ffc2fa203804163c91f3aa894660a40e.

1r3n33 commented 3 years ago

Thank you for the fix @MrCreeper1008.

Here is an alternative version with conditional checks and tests: https://github.com/1r3n33/react-bulma-components/commit/278f6a8d3ea0da2847748dac4de151f5994b245c

kennethnym commented 3 years ago

ahh yes i forgot about testing. do you mind pulling in the test code and make a PR for it?