Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Component inside of <option> is not handled as STRING #13699

Closed
michalica opened this issue Sep 20, 2018 · 2 comments
Closed

Component inside of <option> is not handled as STRING #13699

michalica opened this issue Sep 20, 2018 · 2 comments

Comments

@michalica
Copy link

michalica commented Sep 20, 2018

What is the current behavior?
We use react-intl to do translations in our project. Since 16.5.0 release of react-dom we cannot use this anymore. <option><FormattedMessage id="something"></option>.

If we use that snapshot tests don't fail(we use react-test-renderer). When u look on rendered html there is a string rendered in option tag.

What is the expected behavior?
Tests failing. If we have any react component in option tag we expected to [Object Object] to be rendered inside of option.
Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?

we use create-react-app. it only occurs is test env.
react, react-dom, react-test-renderer 16.5.1
react-int 2.6.0

@gaearon
Copy link
Collaborator

gaearon commented Sep 20, 2018

Please see #13586.

The React DOM behavior is intentional. It’s not supported to put custom components inside <option> and it worked in some cases by accident but crashed in others. So we changed it to not work consistently. With FormattedMessage, you can either use tagName (https://codesandbox.io/s/6yr4xy5ll3) or a render prop (#13586 (comment)).

You’re right this unfortunately wouldn’t reflect in the test renderer. This is because it intentionally doesn’t have DOM specific behavior. So it wouldn’t catch this problem. This is not something we plan to change because it needs to remain agnostic for other use cases.

@gaearon
Copy link
Collaborator

gaearon commented Jun 10, 2021

This is fixed in 18 Alpha.
https://codesandbox.io/s/thirsty-austin-yzgyg?file=/src/index.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants