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

Invariant violation error message improvement #7065

Closed
starkch opened this issue Jun 17, 2016 · 4 comments
Closed

Invariant violation error message improvement #7065

starkch opened this issue Jun 17, 2016 · 4 comments

Comments

@starkch
Copy link
Contributor

starkch commented Jun 17, 2016

Do you want to request a feature or report a bug?
Error message bug.

What is the current behavior?
Uncaught Invariant Violation: img is a void element tag and must not have children or use props.dangerouslySetInnerHTML. Check the render method of

provide the steps to reproduce and if possible a minimal demo of the problem via https://jsfiddle.net or similar (template: https://jsfiddle.net/reactjs/69z2wepo/).**

    render: function () {
        return ( 
            <div  >
                <img src={ this.props.track_artwork } >   </img>
            </div>
         );
       }

What is the expected behavior?

Uncaught Invariant Violation: img is a void element tag and must not have `children` nor use `dangerouslySetInnerHTML`. Check the render method of <Component Name>

Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?

"version": "16.0.0-alpha"

found in Chrome, but should be universal.

starkch pushed a commit to starkch/react that referenced this issue Jun 17, 2016
@jimfb
Copy link
Contributor

jimfb commented Jun 17, 2016

This is expected behavior. img is a void element tag and must not have children. That includes whitespace.

Use <img src={ this.props.track_artwork } /> instead.

@jimfb jimfb closed this as completed Jun 17, 2016
@zpao
Copy link
Member

zpao commented Jun 17, 2016

The issue is that the error itself could use some language improvement.

@zpao zpao reopened this Jun 17, 2016
@linoleum-js
Copy link

@starkch It works for me https://jsfiddle.net/apn1p0gg/1/
Can you give a full code snippet that reproduce it?

@starkch
Copy link
Contributor Author

starkch commented Jun 20, 2016

@linoleum-js; @zpao The issue is that the error message itself could use some improvement. Several of us were working on some code and found the current message unclear.

zpao pushed a commit that referenced this issue Jul 8, 2016
* addresses issue #7065

* fix test to use new message

* fix string in tests

* fix test string

* Update error message and tests

(cherry picked from commit f949125)
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

4 participants