question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Feature request: allow option value to be set to an object

See original GitHub issue

Copy 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.

  1. Values that aren’t strings or numbers aren’t handled: https://github.com/JedWatson/react-select/blob/46ca406244704bba5e1e4adf63bc38dda1fb8fc8/src/Select.js#L423
  2. 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:closed
  • Created 7 years ago
  • Reactions:19
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
bladeycommented, May 27, 2020

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.

1reaction
ebonowcommented, Nov 28, 2020

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:

  1. The original post is over 4 and half years old.
  2. The original use case is for a v1 beta which has been long depreciated.
  3. The expected behavior described in the initial post is no longer an issue (per the above example).
  4. There are no other unresolved questions.

IF there are other questions and concerns, please feel to object, but I see no reason not to let this rest in peace.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found