sanusart / react-dropdown-select

Customisable dropdown select for react
https://react-dropdown-select.netlify.app/
MIT License
352 stars 82 forks source link

Simple setup not working? #167

Closed douglasrcjames closed 3 years ago

douglasrcjames commented 3 years ago

No idea how I am messing this up, but the items are not appearing in my select menu, they seem to be white text, invisible, or I don't know. You can click items and the console log shows the item clicked. When you click the select again, all items are highlighted.

Here is my code sandbox as simple as possible: https://codesandbox.io/s/dawn-brook-tgdyj?file=/src/App.js

sanusart commented 3 years ago

You need to map some of the options properties to label and value. Or use props provided to tell the select what is the key of the value and what is the key for the label

On Fri, Mar 19, 2021, 1:52 AM Douglas James @.***> wrote:

No idea how I am messing this up, but the items are not appearing in my select menu, they seem to be white text, invisible, or I don't know. You can click items and the console log shows the item clicked. When you click the select again, all items are highlighted.

Here is my code sandbox as simple as possible: https://codesandbox.io/s/dawn-brook-tgdyj?file=/src/App.js

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/sanusart/react-dropdown-select/issues/167, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACBLRRDK6ZZKY7K4M46CYLTEKG3JANCNFSM4ZNW4Q2Q .

douglasrcjames commented 3 years ago

Gotcha, I fixed it by adding the props labelField={"name"} and valueField={"name"} to the <Select /> component. It seems these two props are necessary for the minimum viable setup, so I feel these should be mentioned in the docs more clearly as I was searching for a while!

sanusart commented 3 years ago

Not nessesery. You also can have the data mapped. Label and value are just the defaults. This props exist to allow to remap the data without tampering with it. Or in cases where label or value are nested in the data. Adding to the docs is a good idea.