Cannot use <table> - "Hydration failed" - HTMLUnknownElement #36754
-
I cannot make a simple table using Next.js. The page crashes in browser with My environment is Next.js 12.1.4 in Windows 10 (WSL). Steps to reproduce
Note: this example table was taken directly from MDN.
Expected resultCorrect rendering of a table without errors. Actual resultPage with table does render, but a big modal div is displayed over the page with the contents below -- view screenshot here.
|
Beta Was this translation helpful? Give feedback.
Replies: 8 comments 12 replies
-
Hello! I'm not sure why this is happening (as the HTML is valid) but it could be fixed by wrapping the content on the table with a
|
Beta Was this translation helpful? Give feedback.
-
I am experiencing the same problem. In the end I changed all table HTML elements to divs and it's working fine now, but I am less than happy about it, as this is a workaround. |
Beta Was this translation helpful? Give feedback.
-
Use div instead of table tag, example: <div className="text-xs mt-5 table">
<div className="table-row">
<div className="table-cell text-color-secondary pr-4">Creation time</div>
<div className="table-cell text-color-primary">2022-07-13 08:12:35</div>
</div>
<div className="table-row">
<div className="table-cell text-color-secondary pr-4 pt-2">Founder</div>
<div className="table-cell text-color-primary pt-2">Zhang san</div>
</div>
<div className="table-row">
<div className="table-cell text-color-secondary pr-4 pt-2">Progress</div>
<div className="table-cell text-color-primary pt-2">64%</div>
</div>
</div> |
Beta Was this translation helpful? Give feedback.
-
Adding |
Beta Was this translation helpful? Give feedback.
-
Same issue, even this very simple table used as an example from w3schools: const table = () => (
<table>
<tr>
<th>Company</th>
<th>Contact</th>
<th>Country</th>
</tr>
<tr>
<td>Alfreds Futterkiste</td>
<td>Maria Anders</td>
<td>Germany</td>
</tr>
<tr>
<td>Centro comercial Moctezuma</td>
<td>Francisco Chang</td>
<td>Mexico</td>
</tr>
</table>
); |
Beta Was this translation helpful? Give feedback.
-
I tried using tbody and thead...didnt work for me. Trying other methods now and making it from scratch. |
Beta Was this translation helpful? Give feedback.
-
I face the same issue when adding tfoot
but, changing table to div solve the issue, answered by @hdsuperman
|
Beta Was this translation helpful? Give feedback.
-
Has someone filed this as a bug?? |
Beta Was this translation helpful? Give feedback.
Hello!
I'm not sure why this is happening (as the HTML is valid) but it could be fixed by wrapping the content on the table with a
<tbody>
.