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

Add void-dom-elements-no-children rule #1051

Merged
merged 1 commit into from
Jan 30, 2017

Conversation

lencioni
Copy link
Collaborator

There are some HTML elements that are only self-closing (e.g. img,
br, hr). These are collectively known as void DOM elements. If you
try to give these children, React will give you a warning like:

Invariant Violation: img is a void element tag and must neither have
children nor use dangerouslySetInnerHTML.

This rule prevents this from happening.

Since this is already a warning in React, we should add it to the
recommended configuration in our next major release.

Fixes #709

There are some HTML elements that are only self-closing (e.g. `img`,
`br`, `hr`). These are collectively known as void DOM elements. If you
try to give these children, React will give you a warning like:

> Invariant Violation: img is a void element tag and must neither have
> `children` nor use `dangerouslySetInnerHTML`.

This rule prevents this from happening.

Since this is already a warning in React, we should add it to the
recommended configuration in our next major release.

Fixes #709
Copy link
Member

@ljharb ljharb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, great addition.

@lencioni lencioni merged commit c97dd0f into master Jan 30, 2017
@lencioni lencioni deleted the void-dom-elements-no-children branch January 30, 2017 18:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

2 participants