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

validateDOMNesting(...): <tr> cannot appear as a child of <div> #71

Open
salomvary opened this issue Oct 13, 2020 · 0 comments
Open

validateDOMNesting(...): <tr> cannot appear as a child of <div> #71

salomvary opened this issue Oct 13, 2020 · 0 comments

Comments

@salomvary
Copy link

salomvary commented Oct 13, 2020

This test

test('renders row', () => {
    const Row = () => (
      <tr>
        <td>Hello</td>
      </tr>
    );

    expect(
      <Row />,
      'to deeply render as',
      <tr>
        <td>Hello</td>
      </tr>
    );
  });

Prints this warning:

    console.error
      Warning: validateDOMNesting(...): <tr> cannot appear as a child of <div>.
          in tr (created by Row)
          in Row
          in StatelessWrapper

Workaround:

test('renders row', () => {
    const Row = () => (
      <tr>
        <td>Hello</td>
      </tr>
    );

    expect(
      <table>
        <tbody>
          <Row />
        </tbody>
      </table>,
      'to deeply render as',
      <table>
        <tbody>
          <tr>
            <td>Hello</td>
          </tr>
        </tbody>
      </table>
    );
  });

Could unexpected-react somehow improve the situation by

  1. supressing such warnings
  2. or allowing to control how the rendered nodes are wrapped?
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

1 participant