What is the point of getOptionValue prop ?
See original GitHub issueHi,
The documented getOptionValue prop does not seem to have any effect. Related to #2920
Using these options :
const options = [{ id: 'one', label 'One' }, { id: 'two', label: 'Two' }]
<Select
options={options}
getOptionValue={option => option.id}
/>
getOptionValue
does not seem to do anything :
- In the onChange event handler, the value is still the option object
- passing a string id (example: ‘one’) as value does not select the correct option
- worth, passing an object like
{ id: 'one' }
as value does not select the correct option
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:6
Top Results From Across the Web
react-select change name of option fields from ({ value: '', label ...
Use getOptionLabel and getOptionValue props. <Select getOptionLabel={option => option.name} getOptionValue={option => option.id} ...
Read more >Advanced - React Select
React Select exposes a variety of eventListeners to you via props. The onchange function prop now has the following signature.
Read more >org.apache.commons.cli.CommandLine.getOptionValue java ...
Parses the input args with a command line format, using * {@link org.apache.commons.cli.CommandLineParser}. * * @param args the input args * @return true...
Read more >How to Get Selected Value from a Mapped Select Input in React
... can be a little tricky as you need to think from a data point of view ... Assign the value property from...
Read more >CommandLine (Apache Commons CLI 1.5.0 API)
Gets an array of the processed Option s. String · getOptionValue(char opt). Retrieve the first argument, if any, of this option.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thank you @Rall3n, it now makes sense ! This should be documented because it’s really confusing
@Rall3n thanks for explanation. In this case, shouldn’t you consider adding some warning when user provides any option without
{value: string}
? As I said, the only error I got was from React complaining about null ininput[value]
and it needed some research to find out that I should usegetOptionValue
. And from what you say, it seems thatreact-select
would become glitchy also in a bunch of other ways when someone doesn’t use{value: string}
, although it seems to be supported at first sight.