Nextui 表格,表格主体内带有自定义组件

问题描述 投票:0回答:1

我正在使用 NextUI Table 组件。

  • 这是文档的预期用法:
  <Table aria-label="Example static collection table">
      <TableHeader>
        <TableColumn>NAME</TableColumn>
        <TableColumn>ROLE</TableColumn>
        <TableColumn>STATUS</TableColumn>
      </TableHeader>
      <TableBody>
        <TableRow key="1">
          <TableCell>Tony Reichert</TableCell>
          <TableCell>CEO</TableCell>
          <TableCell>Active</TableCell>
        </TableRow>
      </TableBody>
    </Table>
  • 我想要实现的只是渲染一个自定义组件,该组件返回与 TableBody 内部完全相同的代码。它看起来像这样:
 <Table aria-label="Example static collection table">
      <TableHeader>
        <TableColumn>NAME</TableColumn>
        <TableColumn>ROLE</TableColumn>
        <TableColumn>STATUS</TableColumn>
      </TableHeader>
      <TableBody>
        <Test id="1" key="1" />
      </TableBody>
    </Table>
const Test = ({id}: {id: string}) => (
  <TableRow key="1">
    <TableCell>Tony Reichert</TableCell>
    <TableCell>CEO</TableCell>
    <TableCell>Active</TableCell>
  </TableRow>

上述方法返回此错误:

TypeError: type.getCollectionNode is not a function

我的问题是:我是否做错了什么,或者由于 NextUI 的限制,这根本不可能。这两个代码示例有何不同?

没有太多尝试,只是似乎不起作用

reactjs nextui
1个回答
0
投票

根据@Tim van Dam 评论,目前似乎不可能

© www.soinside.com 2019 - 2024. All rights reserved.