[bug][16.5.0] option returns [object Object] instead of string
See original GitHub issueWhat is the current behavior?
<option> returns [object Object] instead string
Demo: https://codesandbox.io/s/ww5mv2w957
What is the expected behavior? Expected string
Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?
Issue Analytics
- State:
- Created 5 years ago
- Reactions:10
- Comments:29 (13 by maintainers)
Top Results From Across the Web
node js function return [object Object] instead of a string value
i am quiet new to java script and node js, i am trying to get a value from a MySQL DB, and the...
Read more >How to set selected option dynamically in Angular 6 - Medium
Selects in Forms are great when you have multiple options. In Angular as a OPTION value we can use not only string literals,...
Read more >Bug listing with status RESOLVED with resolution FIXED as at ...
... Bug:3 - "poedit-1.1.5.ebuild" status:RESOLVED resolution:FIXED severity:normal ... Bug:3549 - "(b)xforms fails to compile a _working_ shared object.
Read more >why it is showing [object object] : r/learnjavascript - Reddit
I think you need to convert the object back to a string first in order to display it. I think instead of setting...
Read more >AURORA: Statistical Crash Analysis for Automated Root ...
the point the program crashes; instead, it might be far earlier ... (which now actually results in a String object) and passed to....
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 Free
Top Related Reddit Thread
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

Since we warned about this before (in 15), and it crashes in unexpected ways, I think the new behavior is actually a bugfix — both for the missing warning, and for inconsistent behavior. It’s very unfortunate that the warnings didn’t get emitted in some cases (to be clear, it did for components returning DOM nodes — but we missed the case for strings). But I think allowing crashes in this case is worse than addressing the problem head on.
The intended workaround if you’re using react-intl is indeed this: https://codesandbox.io/s/6yr4xy5ll3
If you use something else, just make what you’re passing to
<option>as a child is actually a string: https://codesandbox.io/s/oom712ov79Both of these cases don’t crash on updates, and work correctly. Again, very sorry we only discovered this now.
If anyone still needs an answer to the original question, as mentioned in earlier comments and in the documentation here, you cannot use a formatted message in the format of
instead I’ve found formating it as such does work:
where
txtwill return the id’s default string for whichever Message Descriptor file is selected