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

Warn and remove when a known attribute of a DOM component receives a Symbol as a value. #10512

Closed
flarnie opened this issue Aug 22, 2017 · 3 comments

Comments

@flarnie
Copy link
Contributor

flarnie commented Aug 22, 2017

Do you want to request a feature or report a bug?
This is a possibly incorrect corner case which we should correct before finalizing the new behavior of unknown attributes. (See #10399 for more context on the changes to behavior with unknown attributes.)

If this happens with unknown attributes, we want to warn and then remove the attribute. The behavior should be consistent between known and unknown attributes.

What is the current behavior?
We currently throw a generic error when a Symbol is passed to a known attribute which expects a string.

var Hello = React.createClass({
  render: function() {
    return <div className={Symbol('foo')}>Hello {this.props.name}</div>;
  }
});
// rendering this throws "TypeError: can't convert symbol to string  react-dom.js:2028:11"

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem via https://jsfiddle.net or similar (template: https://jsfiddle.net/84v837e9/).

Example:
https://jsfiddle.net/675gk050/1/

Also happens with spreading of objects in as props:
https://jsfiddle.net/2m985yt1/2/

What is the expected behavior?
We should warn and remove the attribute, since that is not a valid value.

Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?
Recent react (15.*) and 16-beta as well.

@aweary
Copy link
Contributor

aweary commented Sep 15, 2017

Hey, @flarnie! What's the status of this? It looks like in the latest 16 RC it does warn instead of throwing a generic error. Can this be closed?

@gaearon
Copy link
Collaborator

gaearon commented Sep 15, 2017

Yes.

@gaearon gaearon closed this as completed Sep 15, 2017
@flarnie
Copy link
Contributor Author

flarnie commented Sep 16, 2017

Double-yes and thanks @gaearon

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

3 participants