Skip to content

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