react-selectrix icon indicating copy to clipboard operation
react-selectrix copied to clipboard

Prop type warning when passing a non String value as a key

Open bampisSyk opened this issue 7 years ago • 3 comments

Issue description

I've came across a proptype warning when passing an int as options key. focusItem is declared as a string in App.js seems reasonable enough so i think a simple conversion is enough as a think many people may try to pass an int as the option key, my case was passing the product_id from a an api.

I know that this is against the PropTypes use but i think an exception here adds some kind of flexibility

Steps to reproduce the issue

Just pass an int as the options key, you can try it in the PlayGround.js file

What's the expected result?

I think a conversion, maybe wrong

What's the actual result?

A proptype warning

Additional details / screenshot

image

A fix maybe https://github.com/bampisSyk/react-selectrix/commit/9a987e60bf4db1a58c048f00e78bb4f8152f33bc

bampisSyk avatar Jul 12 '18 19:07 bampisSyk

Very nice remark!

Is "focusedItem" the only prop related to options, that excepts a string? Or we should consider normalize all the options before we pass it down to the component?

A pull request will be really helpful! Thanks a lot

stratos-vetsos avatar Jul 12 '18 20:07 stratos-vetsos

About to do some more digging... i'll post back the results

bampisSyk avatar Jul 12 '18 20:07 bampisSyk

Any feedback on this?

stratos-vetsos avatar Aug 03 '18 21:08 stratos-vetsos