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.

Add support for Symbols as option values.

See original GitHub issue

Lets say I have two arrays, and I want to use React Select to allow a user to create a mapping from people to pets.

const people = ['amy', 'bob', 'callum']
const pets = ['cat', 'dog']

Next to each item in people there is a React Select dropdown allowing the user to select which item from pets to map that person too, or a None option if they are not mapped to a pet. Currently, the value on the None option is a string constant: '_none'.

However, since my arrays are user-generated, and I want to allow any string value in my arrays, it is possible that the string '_none' could appear in one of my arrays, which would break my implementation.

To work around this I’d like to use a Symbol as the value of the None option, because then it would always be unique and never clash with a literal string value of '_none', but when I do this I get an error.

Uncaught TypeError: Cannot convert a Symbol value to a string

I think this error is thrown at /src/utils/defaultMenuRenderer.js L37.

I could use .toString() on my Symbol, but that would raise the same conflict concerns as above.

Are there any reasons not to support Symbol types as values? Do you have possible work arounds? If not, I’d be happy to send a PR to add support for symbols as values.

Let me know if you need any clarification on my problem. Thanks for the awesome library ❤️

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
ebonowcommented, Mar 18, 2021

The default behavior of react-select is to stringify both the value and label so typing can filter on both. This can be modified by setting a stringify function on customFilter

0reactions
Nokel81commented, Mar 18, 2021

Ah oops I was using 3.X. Though I still don’t see why they need to be stringified.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Changing select values with < and > in value - Stack Overflow
I'm running into issues when it comes to using the less than (<) and greater than (>) symbols. It works for all the...
Read more >
Insert a symbol - Microsoft Support
Go to Insert > Symbol. Symbol command on the Insert tab. Pick a symbol, or choose More Symbols. Scroll up or down to...
Read more >
How to Use Symbols in Drop Down List in Excel - YouTube
In this tutorial, learn how to use symbols in drop-down lists in Excel.You can use only symbols or a combination of symbols and...
Read more >
Unique values—ArcGIS Pro | Documentation
Unique values symbolize qualitative categories of values. Examples include habitat types, planning zones, voting preferences, and soil classifications.
Read more >
Symbol - JavaScript - MDN Web Docs
Chrome Edge Symbol Full support. Chrome38. Toggle history Full support. Edge12. footnote... @@toPrimitive Full support. Chrome47. Toggle history Full support. Edge15. Toggle... Symbol() constructor Full support....
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