Feature request: allow option value to be set to an object
See original GitHub issueCopy of #572 since there seemed to be a misunderstanding of the core issue there. The desire here is to be able to set options that look like this:
var options = [
{label: 'item 1', value: {id: 123, foo: 'bar'},
{label: 'item 2', value: {id: 456, foo: 'baz'}
]
The reason this doesn’t work currently is because of how this.props.value
is interpreted to display the selected option.
- Values that aren’t strings or numbers aren’t handled: https://github.com/JedWatson/react-select/blob/46ca406244704bba5e1e4adf63bc38dda1fb8fc8/src/Select.js#L423
- Even if they were,
===
is not sufficient for comparing objects: https://github.com/JedWatson/react-select/blob/46ca406244704bba5e1e4adf63bc38dda1fb8fc8/src/Select.js#L427
Is setting values to objects a feature react-select is interested in supporting? If so, would it be okay to add a dependency on an object deep equality checker like node-deep-equal?
Issue Analytics
- State:
- Created 7 years ago
- Reactions:19
- Comments:7 (1 by maintainers)
Top Results From Across the Web
The HTML Option element - MDN Web Docs - Mozilla
The content of this attribute represents the value to be submitted with the form, should this option be selected. If this attribute is...
Read more >Advanced Usage — Requests 2.28.1 documentation
This document covers some of Requests more advanced features. Session Objects¶. The Session object allows you to persist certain parameters across requests. It ......
Read more >jQuery API Documentation
jQuery is a fast, small, and feature-rich JavaScript library. ... Create a new jQuery object with elements added to the set of matched...
Read more >Invoke-WebRequest (Microsoft.PowerShell.Utility)
The Invoke-WebRequest cmdlet sends HTTP and HTTPS requests to a web page or ... Using Get-Item on the avatar key, the FileInfo object...
Read more >Reference: Block elements - Slack API
An array of option objects. A maximum of 10 options are allowed. initial_options. Object[]. No. An array of ...
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
Hello -
In an effort to sustain the
react-select
project going forward, we’re closing old issues / pull requests.We understand this might be inconvenient but in the best interest of supporting the broader community we have to direct our limited efforts to maintain the latest version.
If you feel this issue / pull request is still relevant and you’d like us to review it, please leave a comment and we’ll do our best to get back to you.
Greetings @vasilevich ,
The implementation for using objects as values seems fairly straight forward. Given this codesandbox example, what other questions or documentation is unclear?
I believe this should be marked resolved and closed given:
IF there are other questions and concerns, please feel to object, but I see no reason not to let this rest in peace.