我一直无法弄清楚如何有条件地关闭现有的 JSX 标记并开始一个新的标记,而不会在 Visual Studio 中出现语法错误。这是怎么做的?在下面的示例中,我想将现有表拆分为两个表。如果我删除条件代码,我不会收到任何语法错误。
<table>
<thead>
...
</thead>
{true ?
</table> /* Close first table (Syntax error on this line because of no starting tag) */
<table> /* Create a new table by splitting the existing table */
: null}
<tbody>
...
</tbody>
</table>