Skip to content

validateDOMNesting incorrectly validates table children #12674

Description

@mindtraveller

Do you want to request a feature or report a bug?

bug

What is the current behavior?

validateDOMNesting shows warning when table element has tr element as a direct child

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem. Your bug will get fixed much faster if we can run your code and it doesn't have dependencies other than React. Paste the link to your JSFiddle (https://jsfiddle.net/Luktwrdm/) or CodeSandbox (https://codesandbox.io/s/new) example below:

Please find the example copied from MDN (the first HTML example): https://codesandbox.io/s/8z5wyo2.
Open browser's console and run it. In the console you will see warning: validateDOMNesting(...): <tr> cannot appear as a child of <table>. Add a <tbody> to your code to match the DOM tree generated by the browser.

What is the expected behavior?

According to MDN table could have tr as a child (there are such examples on their pages here and here), so I'd expect that warning does not appear

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

The issue is found in v16.x.x in Chrome / FF. It may affect other browsers and prior versions

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions