-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Dropdown onChange #1571
Comments
Sure you can do that.
|
data.options gives me all my options..how do I know which one got selected? is there an array index that I get with the event? |
|
but that would require looping through the array of objects and seeing which value equals data.value. It seems like if the array index was provided with the event it would be a lot more efficient. |
You shouldn't worry too much about iterating though an array. It's a fairly simple operation and a standard practice. If you are keen on avoiding the iteration, you can have |
oh, good idea :) |
And if you have more than one option with the same value? |
I would propose to keep your values unique. Consider also the reverse case, if there are several duplicate values, which one does the Dropdown select when used as a controlled component? There would be no way to know for sure. |
is there a way to get more than just the value from the onChange event? I'd like to get other values from the objects defined in options.
eg:
The text was updated successfully, but these errors were encountered: