managerial-maroonM
Refine2y ago
12 replies
managerial-maroon

Set type of table record using useTable

How do I set a type to my table records? I'm currently using Ant Design and the useTable() hook. What changes do I need to make in order to avoid the error commented in my code snippet?

const { tableProps } = useTable({
  syncWithLocation: true,
});

return (
  <List>
    <Table {...tableProps} rowKey="id">
      <Table.Column
        render={(_, record) => (
          <Space size="middle">
            <a>Invite {record.name}</a> <!-- 'record' is of type 'unknown'.ts(18046) -->
            <a>Delete</a>
          </Space>
        )}
        dataIndex="id"
        title={translate("fields.id", "ID")}
      />
      <!-- ... -->
    </Table>
  </List>
)
Was this page helpful?